G
Guest
Hello
I am using asynchronous delegates to make a call to a COM ActiveX object, but even though the call occurs on a separate thread, my UI is still blocking.
If i put the thread to sleep in my delegate call, the application is well behaved (no UI freeze), but the call to the com object causes the UI to lock up
Do I have to manage calls to an ActiveX object differently than using the BeginInvoke and a callback
A sample of the code I am using
/// <summary
// Connect to the devic
/// </summary
/// <returns></returns
public bool BeginConnect(
bool bRetVal = false
IAsyncResult ar
int threadId
// Create the delegate
AsyncDelegate dlgt = new AsyncDelegate(m_ad.AutoConnect)
threadId = AppDomain.GetCurrentThreadId()
Console.WriteLine("In BeginConnect Calling BeginInvoke from {0}.", threadId)
// Initiate the asychronous call. Include an AsyncCallbac
// delegate representing the callback method, and the dat
// needed to call EndInvoke
ar = dlgt.BeginInvoke( out threadId, new AsyncCallback(AutoConnectCallback), dlgt )
bRetVal = ar.IsCompleted
return bRetVal
public int AutoConnect(out int threadId)
int ret = 0
Console.WriteLine("Begin Call to: AutoConnect.")
threadId = AppDomain.GetCurrentThreadId()
// ActiveX call that blocks
m_driver.AutoConnect()
Console.WriteLine("End Call to: AutoConnect.")
return ret
I am using asynchronous delegates to make a call to a COM ActiveX object, but even though the call occurs on a separate thread, my UI is still blocking.
If i put the thread to sleep in my delegate call, the application is well behaved (no UI freeze), but the call to the com object causes the UI to lock up
Do I have to manage calls to an ActiveX object differently than using the BeginInvoke and a callback
A sample of the code I am using
/// <summary
// Connect to the devic
/// </summary
/// <returns></returns
public bool BeginConnect(
bool bRetVal = false
IAsyncResult ar
int threadId
// Create the delegate
AsyncDelegate dlgt = new AsyncDelegate(m_ad.AutoConnect)
threadId = AppDomain.GetCurrentThreadId()
Console.WriteLine("In BeginConnect Calling BeginInvoke from {0}.", threadId)
// Initiate the asychronous call. Include an AsyncCallbac
// delegate representing the callback method, and the dat
// needed to call EndInvoke
ar = dlgt.BeginInvoke( out threadId, new AsyncCallback(AutoConnectCallback), dlgt )
bRetVal = ar.IsCompleted
return bRetVal
public int AutoConnect(out int threadId)
int ret = 0
Console.WriteLine("Begin Call to: AutoConnect.")
threadId = AppDomain.GetCurrentThreadId()
// ActiveX call that blocks
m_driver.AutoConnect()
Console.WriteLine("End Call to: AutoConnect.")
return ret