0

Hi,
I am having an small application which is running in a thread and it is waiting for an event initially. As soon as if i clicked the START button, event will be enabled. From then onwards my entire application is running in WHILE (TRUE) loop. That means that i want to run my application continuously. As soon as if i clicked the STOP button, i am reseting the event and exiting the application. But here i am facing one problem. Once if i clicked the STOP button, my application is hanging. Can any one give me some ideas, to overcome this problem.

Additional Information: -

1) I have created the class library for my application. ( This creates DLL for my application )

2) In order to test my application, i have created the small form based application which will call my actual application

3) I have included that DLL as a reference in the reference list, in the Form based application

4) I have used the "ManualResetEvent" Class to handle the events.

Please give me the solution. It's urgent. Reply back to me if anyone needs more inputs.

Regards,
Vijay Bhaskar

4
Contributors
3
Replies
6
Views
9 Years
Discussion Span
Last Post by kataraja5
0

Instead of using a while(TRUE) loop can't you use a variable while(keepLooping) and when the stop button is pressed you change keepLooping to false?

0

Yeah, your problem is the while (true), you need to have some sort of shutdown flag, something like:

internal static bool Shutdown = false;

private static void Main()
{
     while (!Shutdown)
     {
             // Do stuff here
     }
}

And when you click your stop button, do "Shutdown = true;".

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.