Moving mouse aroung causes events to stop firing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am pressing on a buttom which performs some action and waits for an event.
When I mouse the mouse around the screen while waiting, all events stop
firing.
I can't click on other buttons and have to forcefully shut down my
application.

Has anyone had this problem? Any ideas on how to fix it?

Thanks,

Herb
 
Hi Ginny,

Thanks for your reply.

We'll I think I applied SP2 some time ago, but I'm not sure where to get
version information for the CF. Do you know how the get the version info?
 
I have SP2. I'm not using anything unusual
I click on a button. The button_click calls a function which send a packet
to a server. The server response and an event is fired to the the form which
has the button.

If I move the mouse around after pressing the button, all events stop firing.

Very weird.

Anyone?

Thanks again
 
Does the function run on a separate thread? Or is the call to the server
asynchronous?

--
Ginny Caughey
..Net Compact Framework MVP
 
You're using a synchronous blocking call on the UI thread. Move it to a
worker thread.

-Chris
 
Same thread with synchronous sockets. I'll create a worker thread and see
what happens.

Thanks for your help
 
I will take your suggestion and create a worker thread for my synchronous
socket events.

Thanks
 
I do start a thread after the socket has been connected
in the following simplified code from my socket class

public delegate void LoginAcceptedHandler(object sender);
public event LoginAcceptedHandler OnLoginAccepted;

public void Connect()
{
... socket initialization code here
_socket.Connect
Thread threadProcessServerData = new Thread(new
ThreadStart(ProcessServerData));
threadProcessServerData.Start();
}

//handler reading the datastream coming from the server
private void ProcessServerData()
{
byte[] data;
while (true)
{
data = ReceiveVarData(_socket);
if (data.Length == 0)
break;
... some switch case statements here
case ServerMessages.LoginOK:
OnLoginAccepted (this);
break;

}

Ok,

I have a form which has in instance of my socket client class.
It subscribes to its events.

When click a button on my form I send a socket message to some server which
then responds back to the client. I get stuck here. I have a thread in my
socket class already, where else should I create a thread?

I don't want thread all over the place everytime I received and event from
my socket client class. So what am I doing wrong?
 
I think you need to step back and go through a threading tutorial.
Basically you need to have a single thread that runs all your socket
operations that is separate from your UI. When something of interest
happens, that thread needs to either fire an event or call Invoke (if you
use an event, remember that the handler is in the thread context, so if you
need to update the UI, you must call Invoke) to do what you want.

-Chris


Opa said:
I do start a thread after the socket has been connected
in the following simplified code from my socket class

public delegate void LoginAcceptedHandler(object sender);
public event LoginAcceptedHandler OnLoginAccepted;

public void Connect()
{
... socket initialization code here
_socket.Connect
Thread threadProcessServerData = new Thread(new
ThreadStart(ProcessServerData));
threadProcessServerData.Start();
}

//handler reading the datastream coming from the server
private void ProcessServerData()
{
byte[] data;
while (true)
{
data = ReceiveVarData(_socket);
if (data.Length == 0)
break;
... some switch case statements here
case ServerMessages.LoginOK:
OnLoginAccepted (this);
break;

}

Ok,

I have a form which has in instance of my socket client class.
It subscribes to its events.

When click a button on my form I send a socket message to some server which
then responds back to the client. I get stuck here. I have a thread in my
socket class already, where else should I create a thread?

I don't want thread all over the place everytime I received and event from
my socket client class. So what am I doing wrong?



Chris Tacke said:
You're using a synchronous blocking call on the UI thread. Move it to a
worker thread.

-Chris
 
Hye Chris,

Thanks for your continued help. We'll I do have a single thread running all
my socket operations after I successfully connect. This thread calls a
procedure that infinately loops waiting for socket data.

Once I get this data, I fire an internal event to a subscriber that happens
to be a form. I am not calling invoke method which should do the trick.

I will try this.

Thanks a lot.

Chris Tacke said:
I think you need to step back and go through a threading tutorial.
Basically you need to have a single thread that runs all your socket
operations that is separate from your UI. When something of interest
happens, that thread needs to either fire an event or call Invoke (if you
use an event, remember that the handler is in the thread context, so if you
need to update the UI, you must call Invoke) to do what you want.

-Chris


Opa said:
I do start a thread after the socket has been connected
in the following simplified code from my socket class

public delegate void LoginAcceptedHandler(object sender);
public event LoginAcceptedHandler OnLoginAccepted;

public void Connect()
{
... socket initialization code here
_socket.Connect
Thread threadProcessServerData = new Thread(new
ThreadStart(ProcessServerData));
threadProcessServerData.Start();
}

//handler reading the datastream coming from the server
private void ProcessServerData()
{
byte[] data;
while (true)
{
data = ReceiveVarData(_socket);
if (data.Length == 0)
break;
... some switch case statements here
case ServerMessages.LoginOK:
OnLoginAccepted (this);
break;

}

Ok,

I have a form which has in instance of my socket client class.
It subscribes to its events.

When click a button on my form I send a socket message to some server which
then responds back to the client. I get stuck here. I have a thread in my
socket class already, where else should I create a thread?

I don't want thread all over the place everytime I received and event from
my socket client class. So what am I doing wrong?



Chris Tacke said:
You're using a synchronous blocking call on the UI thread. Move it to a
worker thread.

-Chris


Hi,

I am pressing on a buttom which performs some action and waits for an
event.
When I mouse the mouse around the screen while waiting, all events stop
firing.
I can't click on other buttons and have to forcefully shut down my
application.

Has anyone had this problem? Any ideas on how to fix it?

Thanks,

Herb
 
Back
Top