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

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?

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;".

lanza kodaka threads nerchoko ra muttak na madda

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.