Login  
Search All Forums
Dart Home | PowerTCP Sockets for .NET | Custom Development Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums   
AuthorForum: PowerTCP Sockets for .NET (Secure and Standard)
Topic: Async Socket and Form Loads
darthwerk

From: Pensacola, FL USA
Posts: 3
Member Since: 02/11/04
posted February 11, 2004 12:24 AM

I've written a dll that uses the TCP object. I've got an event that fires after processing an async receive event. That event then creates a new instance of a form and calls .Show() on it. The form never loads, it becomes unresponsive after calling show. It's not something in the form itself, because it will load outside of the event. My question is that it's trying to load that form on a worker thread from the async socket. Abbreviated code is below.

//Event delegate
public delegate void MessageEventHandler(object sender, MsgEventArgs Msg);


public class clsConnection
{
private Dart.PowerTCP.Sockets.Tcp m_oTcp = new Dart.PowerTCP.Sockets.Tcp();
private byte[] Buffer;

// Event
public event MessageEventHandler MessageReceived;

private void m_oTcp_EndReceive(object sender, Dart.PowerTCP.Sockets.SegmentEventArgs e)
{
   string tmpString = "";
   tmpString = e.Segment.ToString();

   .....Data Processing code.....

//MsgEventArgs is a class containing data from the socket
MessageReceived(this, new MsgEventArgs(MsgStanza))
}

}




// This is the code in form that uses the dll:

private void ServerConnection_MessageReceived(object source, IMCom.MsgEventArgs Msg)
{
   .....Some Processing Code.....


frmIMWindow NewWindow = new frmIMWindow(Msg.MsgStanza.From, this);

NewWindow.Show();

}
}
darthwerk

From: Pensacola, FL USA
Posts: 3
Member Since: 02/11/04
posted February 11, 2004 12:27 AM

Sorry about the poor code formatting. It's hard to get it right in this tiny box. You really should make it a bit bigger. I guess the question is whether or not the async receive is causing this.
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted February 11, 2004 9:06 AM

I can't really tell what you're trying to do from the code posted, but what I can do is suggest a couple things. First, take a look at the samples and see if any of them do something similar. Second, make sure you set DoEvents to true for the Tcp object. Also try setting the Synchronizing object property of the control to the Main form.

darthg8r

From: pensacola, FL USA
Posts: 1
Member Since: 02/11/04
posted February 11, 2004 10:42 AM

Sycronizing object fixed it. Thanks
Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX