none
Encountering Lock on Main Thread (WinForms/Deadlock) RRS feed

  • Question

  • Hi,

    My main thread encounters a 

    lock (mLock){...}

    when first entering a tab in a tab control (i.e. OnEnter handler). It is stopping indefinitely at the lock unless I create a separate thread which executes the code above. What is the reason for this apparent deadlock? All other threads executing that encounter the associated locks are workers. Is the main thread somehow responsible for relinquishing control back to the workers so they cannot run and release the lock. If so, I do not see why. Answers definitely appreciated.

    Thanks for looking,

    Alan

    Saturday, April 23, 2016 12:52 AM

Answers

  • Maybe a worker thread, that acquired the exclusive lock, sends a message (or performs an action that implies messages), which cannot be processed by main thread because of the lock.

    Saturday, April 23, 2016 6:02 PM