Hello Guyz,

How are you all,Again i came with threading problem.please solve me.
I am using C#.net Windows application. my application frequently execute the one
funtion.so i need to go thread.The main thread just execute the thread and return back.when i close the application the main thread stop thread.that is procedure. so i write code like this.

Main thread start the thread
Code:
private void start()
{
     object synobject = new object();
     isthreadrunning = true;
    Thread t = new Thread(new ThreadStart(startthread)
    t.start()
}
Code:
private void startthread()
{
     while(true)
      {
             lock(synobject)
             {
                   if (isthreadrunning == false)
                      return;
              }
             Beginexecute()
             Thread.sleep(1000);
      } 
}
Main thread stop the thread.

Code:
private void stop()
  {
          lock(synobject)
             {
                     isthreadrunning == false;
              } 
            t.abort();    
  }
When Main thread stop the thread..
i wont access the form. is completely blocked. is there any problem in above coding. Please solve this problem..

Thanks in Advance,
Dana