
Signature
Regards,
Phillip Williams (MCPD Web Developer)
http://mcts-study-practices.com/
http://www.webswapp.com
Thanks for your reply Phillip,
For the two questions you mentioned:
** The error in first message seems related to a VS managed debug
assistant. I've searched some former issue and found an existing record,
you can have a look at the following description and test it to see whether
if fits your case:
*** Problem Description ***
The CLR has been unable to transition from COM context 0x1a3608 to COM
context
0x1a3778 for 60 seconds. The thread that owns the destination
context/apartment is
most likely either doing a non pumping wait or processing a very long
running
operation without pumping Windows messages. This situation generally has a
negative
performance impact and may even lead to the application becoming non
responsive or
memory usage accumulating continually over time. To avoid this problem, all
single
threaded apartment (STA) threads should use pumping wait primitives (such
as
CoWaitForMultipleHandles) and routinely pump messages during long running
operations.
*** Resolution *** 08/28/2006 tqchen
This sounds like the ContextSwitchDeadlock Managed Debugging Assistant
(MDA). It can be deactivated by going into Debug | Exceptions and then
uncheck ContextSwitchDeadlock underneath Managed Debugging Assistants.
It can also be deactivated via the app.config. But, I wouldn't just
blindly deactivate this MDA without at least knowing why it's
occurring.
<<<<<<<<<<<<<<<<<<<<<<<<<<
For your second question, if you want to get return value, here is one
means I usually use:
Declare a wrapper class (maybe named ThreadWorker), it has some member
variables that will be used or share data during a thread's execution and
end. And it also contains the member function which is the thread proc.
e.g.
public class ThreadWorker
{
public string Data;
//... other data
public void DoWork()
{
you can update any of the class members here.
.........
}
}
And whenever you want to start a new thread and do some work. YOu can first
create an instance of "ThreadWorker" and use its member function as
threadProc function. Then, after thread finished execution, you can get any
updated data from the class's member variable. How do you think?
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?= <WEBSWAPP@newsgroups.nospam>
>Subject: =?Utf-8?Q?RE:_RE:_WCF_Service_Library:_=E2=80=9Cca?=
> =?Utf-8?Q?nnot_change_thread_mode_after_it?=
> =?Utf-8?Q?_i?=
>Date: Fri, 5 Oct 2007 14:47:02 -0700
>Hi Steve,
>
[quoted text clipped - 14 lines]
>(Tlbimp.exe). After adding the imported COMLib as a reference to my project
>I use the “New�keyword to create an instance of the class that I want
within
>the COM object. That COM object is a black box (I did not write it nor have
>much knowledge about its internal design).
[quoted text clipped - 6 lines]
>
> “Managed Debugging Assistant 'ContextSwitchDeadlock' has detected a
problem
>in 'C:\Documents and Settings\pwilliams\My Documents\Visual Studio
>2005\Projects\SolutionName1\ProjectName1\bin\Debug\ConsoleHost.vshost.exe'.
[quoted text clipped - 8 lines]
>CoWaitForMultipleHandles) and routinely pump messages during long running
>operations.�
>2- Is there another way to launch that STA thread such as to return a value?
> The "Thread" method approach accepts a ParameterizedThreadStart but how can
[quoted text clipped - 45 lines]
>>
>> Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>> ications.
>>
[quoted text clipped - 57 lines]
>> >>
>> >> On the console host, I get a message “cannot change thread mode
after
>> it is
>> >> setâ�echoed on the host console window. If I step using the
debugger
>> through
>> >> the service, I find that it catches a
[quoted text clipped - 9 lines]
>> >>
>> >> Any ideas?
Phillip Williams - 09 Oct 2007 22:53 GMT
Thanks Steven, your solution for returning data from the thread worked fine
for my scenario.
I have not run again into the Managed Debugging Assistant error; I must have
accidently done something that avoided that error.

Signature
Regards,
Phillip Williams (MCPD Web Developer)
http://mcts-study-practices.com/
http://www.webswapp.com
> Thanks for your reply Phillip,
>
[quoted text clipped - 267 lines]
> >> through
> >> >> the service, I find that it catches a
Steven Cheng[MSFT] - 10 Oct 2007 03:11 GMT
Thanks for your followup Phillip,
I'm glad to be of assistance. Yes, that manaed debug error should be
something related to IDE environment.
Have a good day!
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Subject: =?Utf-8?Q?RE:_RE:_RE:_WCF_Service_Library:?=
> =?Utf-8?Q?_=E2=80=9Ccannot_change_thread_mode_afte?=
> =?Utf-8?Q?r?=
>Date: Tue, 9 Oct 2007 14:53:06 -0700
>Thanks Steven, your solution for returning data from the thread worked fine
>for my scenario.
[quoted text clipped - 101 lines]
>> project
>> >I use the “Newâ�keyword to create an instance of the class
that I want
>> within
>> >the COM object. That COM object is a black box (I did not write it nor
[quoted text clipped - 8 lines]
>> >
>> > “Managed Debugging Assistant 'ContextSwitchDeadlock' has
detected a
>> problem
>> >in 'C:\Documents and Settings\pwilliams\My Documents\Visual Studio
[quoted text clipped - 72 lines]
>> >>
>> >> Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>> >> ications.
>> >>
[quoted text clipped - 73 lines]
>> >> >>
>> >> >> On the console host, I get a message “cannot change
thread mode
>> after
>> >> it is
>> >> >> setââ�echoed on the host console window. If I step using
the
>> debugger
>> >> through
>> >> >> the service, I find that it catches a