Detect a CCR Thread RRS feed

  • Question

  • Hi,

    I want to be able to detect if a code is running inside a CCR thread.

    This is done for debug purposes to make sure I'm not executing any blocking code from a CCR thread and causing a dead-lock.

    For now I just use the name of the thread but it is not so great.


    Thank you,


    Monday, December 27, 2010 9:48 AM


  • By using the name, I assume you mean testing whether Thread.Name is the same as the name as you passed to the Dispatcher constructor? This is a perfectly reasonable way to detect not only whether the thread is a CCR thread, but also which CCR Thread Pool it belongs to (if you run multiple dispatchers). Additionally, if you use a constant / literal string (or explicitly intern it), then this check will be about as quick as it can be.

    Nevertheless, I'd be interested in knowing what in particular you don't like about the approach.

    Friday, February 18, 2011 4:19 AM