Re: PInvoke threading issue
From: Peter Huang (v-phuang_at_online.microsoft.com)
Date: 10/06/04
- Next message: Luis Abreu: "Re: ProgID attribute has no effect?"
- Previous message: Mads: "Exposing .Net struct in COM"
- In reply to: Peter Huang: "Re: PInvoke threading issue"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 06 Oct 2004 08:56:36 GMT
Hi,
One possibility is that if the third-party dll called a COM object which is
main threaded that is to say we did not specified the thread model for the
COM Object. In this way, the COM object will be created and running on the
main thread, i.e. the main UI thread which may cause the main UI form
thread blocked. Usually the main thread is the first thread in the process.
So I think you may try to change your code as below.
<code snippet>
[STAThread]
static void Main()
{
//run the winform in the second thread.
Thread th = new Thread(new ThreadStart(ThreadProc));
th.Start();
//Run the P/Inovke code in the main thread, try to replace
the three code lines below
TestCOMP.COMPClass tcc = new TestCOMP.COMPClass();
tcc.SleepVB(1000);
}
public static void ThreadProc()
{
Application.Run(new Form1());
}
</code snippet>
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
- Next message: Luis Abreu: "Re: ProgID attribute has no effect?"
- Previous message: Mads: "Exposing .Net struct in COM"
- In reply to: Peter Huang: "Re: PInvoke threading issue"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|