|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Two threads are accessing my Synclocked codeI'm looking at my debugger right now and can clearly see that two threads
have their execution pointer residing within the same Synclock block. One thread is executing a Monitor.Wait(). I know this suspends the thread but I didn't think this would open the gate for other threads to enter the block. Any ideas what could be happening? Joel Moore Joel Moore <asdads***@asdaadad.com> wrote in
Show quoteHide quote news:Xns98368CE88EECasdsadfgasdgadsa@207.46.248.16: And just to clarify some, here is a snippet of code from the MSDN sample > I'm looking at my debugger right now and can clearly see that two > threads have their execution pointer residing within the same Synclock > block. > > One thread is executing a Monitor.Wait(). I know this suspends the > thread but I didn't think this would open the gate for other threads > to enter the block. > > Any ideas what could be happening? > > Joel Moore > that I derived my own code from. It's the Serial LCD sample: lock (responseSignal) { responsePacket = null; // comPort com.Write(packetXMitBuffer, 0, dataLength + 4); if (Monitor.Wait(responseSignal, MAX_RESPONSE_TIME)) { return responsePacket; } } Elswhere there is a Receive() thread that Pulses the Monitor once the COM port receives enough data. After doing a little more reading it seems that the Monitor.Wait() does release the lock which would imply that this sample code is faulty, no? Seems like I'd need to use a seperate object for the Monitor.Wait() call than what was used to lock the code. "Joel Moore" <asdads***@asdaadad.com> wrote in message Which object are synchronising on and are you sure you are synchronising on news:Xns9836906449125asdsadfgasdgadsa@207.46.248.16... > Joel Moore <asdads***@asdaadad.com> wrote in > news:Xns98368CE88EECasdsadfgasdgadsa@207.46.248.16: > >> I'm looking at my debugger right now and can clearly see that two >> threads have their execution pointer residing within the same Synclock >> block. >> >> One thread is executing a Monitor.Wait(). I know this suspends the >> thread but I didn't think this would open the gate for other threads >> to enter the block. >> the same instance for all threads?
SQL parameter: what is wrong here?
Registry Reading Exporting a vb.net datagrid to excel Formatting text w/VB.NET Abstraction question Calling a VB.NET-DLL FROM VB6 Iterating through the records in a dataset Crystal Reports in VB.NET Determining max number of characters in a TextBox Save Radio Button setting |
|||||||||||||||||||||||