Jarda Posted January 25, 2004 Posted January 25, 2004 Hi guys, I'm developing some project for synchronizing through the SSL channel. This operation takes long time and when you're running in from web, you don't see the progress, that's why I decided to use threads. All is working fine since is the web interface used only by one user. In the moment when another user runs another synchronization, currently running thread is killed and it starts new one. It seems to me there is problem with assigning of slots for new threads. I don't know how to force to create new threads with new unique ID. I'm using following simple code: Dim CoreThread As Thread = New Thread(AddressOf SynchroCore) CoreThread.Priority = ThreadPriority.Highest CoreThread.ApartmentState = ApartmentState.MTA CoreThread.Name = Now.ToString CoreThread.Start() Please can someone help me? Thanks a lot Jarda ================== Jaroslav Lhotak Internet Team Radio Free Europe / Radio Liberty Inc. http://www.rferl.org/ Quote
*Gurus* Derek Stone Posted January 25, 2004 *Gurus* Posted January 25, 2004 You do not need to assign values to the "Name" or "ApartmentState" properties of any thread object. As a matter of fact using the two properties may be causing the issues you describe. I'd strongly suggest removing assignments to "ApartmentState", since its presence it strictly for COM interoperation. Quote Posting Guidelines
Jarda Posted January 26, 2004 Author Posted January 26, 2004 Hi Derek, thanks, but I didn't help. Don't you have any another idea? Something with dataslots ... Thanks a lot Jarda Quote
*Gurus* Derek Stone Posted January 26, 2004 *Gurus* Posted January 26, 2004 A new thread is created with each declaration of a Thread object. The following wil create two threads not two references to the same thread: Dim thread1 As Thread = New Thread(AddressOf Procedure1) Dim thread1 As Thread = New Thread(AddressOf Procedure1) Of course if the HTTP request is completed before the background thread completes the background thread will never finish processing, as it will be killed. In a case such as this you'll need to block the main thread from exiting until the background thread has finished processing. You can do this using asynchronous locks or the Thread.Join() method. Quote Posting Guidelines
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.