JaedenRuiner
Well-known member
- Joined
- Aug 13, 2007
- Messages
- 340
- Programming Experience
- 10+
Okay,
I have Main Thread (VCL Thread, UI Thread, whichever it is called for VB).
I Have the Worker Thread.
Worker thread, Processes database entries, and Generates Word Documents from them, Saves them, and Releases the COM Marshaled Objects and what not, and executing a GC.Collect() on document Close/release so nothing should be accessing the file any more.
Then, though a more convoluted Queue system, the Worker Thread Creates the MailMessage (with the newly created word documnet as the attachment) and then Pushes the Message into the Queue.
If the Queue is empty and no mail is currently being sent, it executes a SendAsync() on the message, and removes it from the Queue. When that Message is completed, (SendCompleted() event) I set my "mailReady" flag and try to send another message (if one has been added to the queue).
However, In that moment, when I'm updating my dataset/datatable/datarow that was sent along as the UserState object with the MailMessage, I also wish to remove the attachment file from the drive, as it is no longer necessary, as Supposedly that email has been sent. Not currently is sending and still needing access to that file, but sent Isn't that what "SendCompleted" means?
Word.exe is no longer in memory at this time, and these files are not being zipped at this time with Shell32, so the only thing that even remotely "could" be accessing this file is the SmtpClient sending algorithm. (Unless of course that damned GarbageCollector is screwing the pooch again, but I am executing a GC.Collect() after I release My Word Document so it Shouldn't be)
So What I need:
I need a poll, or some test that tells me, "Hey, buddy, we're done using that file so you can delete it now." I would expect that Closing the Word Document, (with appropriate COM Marshal Release code and Garbage Collection) and the fact that the SmtpClient.SendCompleted was triggered, nothing else should be accessing the file, but it is, and is crashing the operation.
Thanks
I have Main Thread (VCL Thread, UI Thread, whichever it is called for VB).
I Have the Worker Thread.
Worker thread, Processes database entries, and Generates Word Documents from them, Saves them, and Releases the COM Marshaled Objects and what not, and executing a GC.Collect() on document Close/release so nothing should be accessing the file any more.
Then, though a more convoluted Queue system, the Worker Thread Creates the MailMessage (with the newly created word documnet as the attachment) and then Pushes the Message into the Queue.
If the Queue is empty and no mail is currently being sent, it executes a SendAsync() on the message, and removes it from the Queue. When that Message is completed, (SendCompleted() event) I set my "mailReady" flag and try to send another message (if one has been added to the queue).
However, In that moment, when I'm updating my dataset/datatable/datarow that was sent along as the UserState object with the MailMessage, I also wish to remove the attachment file from the drive, as it is no longer necessary, as Supposedly that email has been sent. Not currently is sending and still needing access to that file, but sent Isn't that what "SendCompleted" means?
Word.exe is no longer in memory at this time, and these files are not being zipped at this time with Shell32, so the only thing that even remotely "could" be accessing this file is the SmtpClient sending algorithm. (Unless of course that damned GarbageCollector is screwing the pooch again, but I am executing a GC.Collect() after I release My Word Document so it Shouldn't be)
So What I need:
I need a poll, or some test that tells me, "Hey, buddy, we're done using that file so you can delete it now." I would expect that Closing the Word Document, (with appropriate COM Marshal Release code and Garbage Collection) and the fact that the SmtpClient.SendCompleted was triggered, nothing else should be accessing the file, but it is, and is crashing the operation.
Thanks