Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB threading or an alternative question

Posted on 2013-07-01
8
Medium Priority
?
200 Views
Last Modified: 2013-07-24
I am currently developing a solution in VB that needs to be able to send a set of emails in the background. I have been able to spin off a new thread to send the emails in the background, which works just fine, but a very serious question has arisen.

"What if the user logs out and closes the application? Will this in-turn close the thread that is sending the emails?"

There is a potential for this background process to be sending out hundreds of emails which could take a significant amount of time ( say 10 minutes or so). One of the instances of this will happen at the end of the users work day and would potentially happen just before the user logs out at the end of the day.

So, to the ultimate question of this post:
Is threading the answer for sending background emails or should I be looking into a different solution?
0
Comment
Question by:Derrick Hammond
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 46

Expert Comment

by:aikimark
ID: 39293134
are you writing this in VB6 or VB.Net?
0
 

Author Comment

by:Derrick Hammond
ID: 39293326
This application is written in vb6.
0
 
LVL 16

Expert Comment

by:HooKooDooKu
ID: 39297214
Sounds like you just need a way to communicate to the 2nd Process.

VB wasn't designed for multi-threading processes, so it takes some creativity on how to effectively communicate.  While I'm sure there are elegant ways to communicate using COM objects and stuff like that, a down and dirty simple example can be to simply communicate through a file.  As an example, you could create a TEMP file in the main process and pass that file name to the 2nd process when you kick it off.  As the 2nd process executes, it can periodically read the contents of this TEMP file to decide what to do.  As an example, if a person logs off the 1st process, the log-off process could update this file to simply contain the text "STOP".  When the 2nd process next checks the content of the TEMP file, it finds "STOP" and aborts the process.

Of course you might have to get a bit more creative if you want to handle situations such as what if the 1st system crashes (in which case, you could start doing things like having the 1st process periodically update the contents of the TEMP file... and the 2nd process only continues to process when it sees the contents of the file change).  You could even have two TEMP files so that the two processes can communicate both ways.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Derrick Hammond
ID: 39302289
My apologies experts.

I miss typed my last reply as to my project being in vb6. I read the question as I was typing and typed in vb6 and sent the comment without rereading my reply.

The project is written in vb.net targeting .net 3.5.

Sorry guys and gals!
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 39302673
>>>What if the user logs out and closes the application? Will this in-turn close the thread that is sending the emails?

Yes - IF the application is closed.  There isn't an easy solution to stopping the user aborting your job.

Simplest  - display a message requesting not to close, close the app yourself when complete
Complex - keep track of what has been sent and at next startup continue where left off.
0
 

Author Comment

by:Derrick Hammond
ID: 39311807
Andy -
How does the thread respond when the isBackground property of the thread is set to false?
Does closing the application kill the process?
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 39314623
There is another option. Create a service for sending the emails out and use the application to just queue the work for service. User logging off or closing application will not affect this service.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question