Sockets and Control.invoke

  • Thread starter Thread starter Derck
  • Start date Start date
D

Derck

Hello All,

I have a question/problem.. I have made a client/server application and i
have problems with control.invoke..
Let me explain my program, because it will be to many code to post..

1. Windows Application (server) with Async .NET Sockets.
2. PDA with Async. .NET Sockets

Now the problem..
- I open a form from the main tread with a normal oForm.Open

- I have a shared connection object with the socket connected to the server
and
i send a get command to the server. I will return some info in XML

- Because it's async it will be done with socket.beginsend and
socket.endsend.

-The result will be received in beginreceive and endreceive (on the pda)

- In the endreceive (on the pda) I will end it and start a new
beginreceive.. After that
I will send the received data to a function (processdata) in the same class,
make an dataset from the received
XML and then raise an event that will fire on the form I opened before..

-In that eventhandler on the form I will do a control.invoke(addresoff Fill)
Control.Invoke is returning correctly from the function fill and all is ok
(I see 2 items in the listview)

- After that I will close the form with me.close

Now when I open the same form again it will hang on the control.invoke It's
never returning from that function and my
whole application is hanging!!! What am I doing wrong here? Is it the socket
thread who starts the update invoke.
Is it the raiseevent in the class?? I have no idea because all is running
good the first time.. I also checked the running programs
in the pda, but i don't see the form in memory anymore..

Another weird thing is when i don't close the form and open the same form
twice it works!?!?!?!?!

Please can someone help me here??

Many thanks in advance!!

Derck Weelink
 
I think the problem is that the form object is diposed after me.close.
so you should to use me.hide, to keep the reference living
or instance the form again.
it hangs because me.invoke is called somewhere in the nirvana ;-)

regards
Milosz Weckowski
 
Hi,

I create a new instance of the form every time.. It seems that there is
still a form in memory
when i call the .invoke again.. I can't hide the form because sometimes
there will be 2 forms open at the same time.. The weird thing here is that
it works when i don't close the first form..

Greets!

Derck
 
Milosz - said:
I think the problem is that the form object is diposed after me.close.
so you should to use me.hide, to keep the reference living
or instance the form again.
it hangs because me.invoke is called somewhere in the nirvana ;-)

regards
Milosz Weckowski
 
Back
Top