views:

189

answers:

1

Hi, I have encountered (for me) very strange problem. In my app, when pressing start button, all threads are activated, when pressing stop button, all threads are aborted and all collections are cleared. This is all happen at the main thread, while other procceses have their own threads or are running via threadpool. However, today I replaced ReaderWriterLock with ReaderWriterLockSlim and rarely, when I press "STOP" button the app will freeze. With Break all I can see the coed is stuck on the line this.someobject.TryEnterWriteLock(-1) and when I display details, the variables are all filled with this message:

"Cannot .... because current thread is in sleep,wait or join state"

I dont understand it - its the main application thread. I do not expect direct answer rather than advice what should I look for, this message I have never seen before. Thank you!

A: 

Do not be confused by the message - it is there because the debugger cannot access the values - your main thread is locked. Why it is locked - there is no saying without the code.

BTW did you try to look at other threads in your app?

mfeingold
But...I have NO locks in the main thread. The methods are ran from different threads and thats why I am asking about the message related to current thread.
Tomas