Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form freezing on event?

Status
Not open for further replies.

zenox0

Programmer
Mar 28, 2005
14
CA
I have a class that I use to monitor a windows service. When the service's status changes it raises an event. In my main form when the event is raised I create a new window to show the user the status has changed. For some reason it freezes my form (the newly created one). The form works perfectly outside of the raised event, its only inside the event that it freezes. Am I not suppost to create objects during an event handler?
 
private void event_fire(object sender, EventArgs e)
{
//Don't create your form here
//Instead call
CreateNewForm();
}

private void CreateNewForm()
{
//Create your form here.
}

<insert stupid signature here>
 
Thanks for the suggestion but it does not work :(

Here is my code that calls the event:

Code:
		private bool CheckStatus ( string currentStatus )
		{
			// If our status havent changed
			if ( currentStatus == lastStatus )
				// Dont do anything
				return ( false );

			string tempLast = lastStatus;
			// Change our last status
			lastStatus = currentStatus;

			// Otherwise
			// If something is watching the event
			if ( null != OnStatusChange && null != tempLast )
				// Raise the event
				OnStatusChange ( tempLast, currentStatus );

			// And its true that we changed status
			return ( true );
		} // End CheckStatus function

And here is my code that handles the event:
Code:
		private void windowsService_OnStatusChange(string oldStatus, string newStatus)
		{
			ShowForum ( );
		}
		private void ShowForum ( )
		{
			MessageForum forum = new MessageForum ( Color.Blue, Color.White, "Test" );
			forum.Show ( );
		}

I know that its not my forum code that breaks because I also have a button with the following click event:

Code:
		private void testButton_Click(object sender, System.EventArgs e)
		{
			CreateNewForm ( );
		}

And this works. Any suggestions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top