An outgoing call cannot be made since the application is dispatching an input-synchronous call

  • Thread starter Thread starter Sagaert Johan
  • Start date Start date
S

Sagaert Johan

Hi

I use an ocx on my form ,when i use a buttons click event to call a method
on the ocx i have no problem.

I made a Socket communication class that invokes an eventhandler through a
delegate.

If i call the ocx method in that handler i get that error.

My eventhandler is invkod with the begininvoke async method.

What is wrong , and how can i solve it ? I think it has something to do
with threading .

any help welcome.

Johan
 
Sagaert,

Why are you using BeginInvoke? Are you doing something on another
thread?
 
yes

I use Socket.beginreceive , the callbackfunction used in beginreceive reeds
the data and then does the begininvoke on the delegate.
I assume i must use the begininvoke since the callbackfunction is executed
on a thread from the threadpool and not on the same thread as my main
application.



Nicholas Paldino said:
Sagaert,

Why are you using BeginInvoke? Are you doing something on another
thread?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Sagaert Johan said:
Hi

I use an ocx on my form ,when i use a buttons click event to call a
method
on the ocx i have no problem.

I made a Socket communication class that invokes an eventhandler through a
delegate.

If i call the ocx method in that handler i get that error.

My eventhandler is invkod with the begininvoke async method.

What is wrong , and how can i solve it ? I think it has something to do
with threading .

any help welcome.

Johan
 
Sagaert Johan said:
yes

I use Socket.beginreceive , the callbackfunction used in beginreceive
reeds
the data and then does the begininvoke on the delegate.
I assume i must use the begininvoke since the callbackfunction is executed
on a thread from the threadpool and not on the same thread as my main
application.

On what thread did you create an instance of the ActiveX object?
Is it the main UI thread or is it another thread?
Do you have calls to DoEvents in your code?

Willy.
 
It was created on the ui thread, meanwhile the problem is solved.

I used the Control.Invoke mechanism from the Socket thread , so the
eventhandler code get executed on the UI thread.

I was a bit misleaded, i tought that the delegate.begininvoke would be the
right solution.

Regards ,Johan
 
Back
Top