|
-
February 19th, 2009, 06:32 AM
#1
Prob w/event handler inside a window opened with Show()
Here's the situation: my application opens one or more child windows with Show() which allow the users to perform several functions, while also being able to click back to the main application.
In each of these child windows I create an event handler, which fires when a new email is received.
This work fine (the event handler is called) however as soon as the code in the event handler begins to execute it just stops. That is, using the debugger I can tell that the event handler has been fired, but when the first line in the handler's code (and this can be something as simple as 'string s = ""'; ) is executed execution of the handler stops.
Is this a threading issue, and is there something I can do to work around it?
Using .Net 3.5SP1
-
February 19th, 2009, 07:36 AM
#2
Re: Prob w/event handler inside a window opened with Show()
Can you provice the code where this is happening?
-
February 19th, 2009, 12:17 PM
#3
Re: Prob w/event handler inside a window opened with Show()
Code:
objOutlook.NewMail += new ApplicationEvents_NewMailEventHandler(objOutlook_NewMail);
sets up the event handler... and
Code:
void objOutlook_NewMail()
{
textBlock2.Text = "Mail Received";
Message ms = new Message("Notice","New mail received");
ms.ShowDialog();
}
is the handler. When the 'textBlock2.Text = "Mail Received"' statement executes, execution stops, the textBlock2.Text property doesn't get updated, nada... execution of the event code just ceases. This is always on the first statement of the event handler, no matter what it is.
-
February 19th, 2009, 01:28 PM
#4
Re: Prob w/event handler inside a window opened with Show()
What happens when you put it in a try/catch
Code:
void objOutlook_NewMail()
{
try
{
textBlock2.Text = "Mail Received";
Message ms = new Message("Notice","New mail received");
ms.ShowDialog();
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
}
I have had similar problem, crashing on a line without throwing an exception. But when I inserted the try/catch, there was an exception caught
-
February 19th, 2009, 08:00 PM
#5
Re: Prob w/event handler inside a window opened with Show()
How can you tell it has fired but then stops?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|