PC Review


Reply
Thread Tools Rate Thread

Application with event handlers won't exit.

 
 
Martin Eyles
Guest
Posts: n/a
 
      14th Apr 2009
I am writing an application that works with a hardware device on the netword
through an SDK. This is designed in such a way that an object created with
the SDK will trigger events in my code, making the application
multi-threaded. Unfortunatley, this is causing a problem where my application
won't exit, and I am not sure if this is related to the thread somehow not
exiting properly. The first point where this occurs is during a device
search. Clicking a button on my UI instantiates an SDK object, and links an
event to my event handler. If I don't click the button I can exit the program
by closing the form. If I do click the button, I can close the form, but the
debugger/task manager show that the application is still running.

I appreciate any help you can give,

Regards,
Martin

The relevant code is:

public partial class Form1 : Form
{
Sirit.Driver.ConnectionDiscovery disc;

private void searchButton_Click(object sender, EventArgs e)
{
disc = new Sirit.Driver.ConnectionDiscovery();
disc.ConnectionFoundEvent += new
Sirit.Driver.ConnectionFound(ConnectionFound);
disc.findConnections();

}

public delegate void DelegateConnectionFound(object sender,
Sirit.Driver.ConnectionInfoArgs e);

public void ConnectionFound(object sender,
Sirit.Driver.ConnectionInfoArgs e)
{
if (this.textBox1.InvokeRequired){
this.textBox1.Invoke(new
DelegateConnectionFound(this.ConnectionFound),new object[]{sender,e});
}
else {
this.textBox1.Text=e.ipaddress;
disc.Stop();
disc.Dispose();
}
}
}
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Application.Exit After Event Fires Chris Fink Microsoft Dot NET Framework Forms 5 17th Mar 2008 01:47 PM
Application Exit Event NeonWilderness Microsoft Access 0 3rd May 2007 06:28 PM
Application Exit Event =?Utf-8?B?Q2hhcmxlcyBUYW0=?= Microsoft Access Form Coding 2 22nd Mar 2005 10:58 AM
How handle exit event in a console application. Jean-Francois Hamelin Microsoft Dot NET Framework 1 3rd May 2004 04:05 AM
Handling the application.exit event Johan Microsoft VB .NET 2 27th Oct 2003 01:56 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:28 PM.