Threads and sharing a window

Hi
I'm programming a GUI for video procesing. In a thread I do the whole process. But I cannot access to the form(window) in the threadfunction back to show the results frame to frame.

Should I use a Semaphore always when ends the frame process??

Thanks in voraus

garrido
Ok, I suppose that my first post was difficult to understand. I`m sorry for that. I try again to explain it better.
I have a mainwindow. If the user clicks a Runbutton then I must process an avi video, and I do that using a thread.... so:
1
2
3
4
5
6
7
8
9
10
private: System::Void buttonRun_Click(System::Object^  sender, System::EventArgs^  e)
         {
            
           // Show a new Window
             ResultsViewer^ formViewer = gcnew ResultsViewer(NFrames,frame, mask, background,readerAvi);
             formViewer->Show();
             // calls a thread
             Thread^ myThread = gcnew Thread(gcnew ParameterizedThreadStart(&ThreadProc1));
             myThread->Start(this);
         }

So my thread takes a parameter the object this, that is my main window....
Hier is what the thread does: (SafeThread was called from delegate ThreadProc1, because I don`t write that)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 static void SafeThread1(System::Object ^obj)
 {
      Form1 ^ob = (Form1^) obj;
      for (ob->i = 0; ob->i<((ob->NFrames)-1); ob->i++)
      {
            ob->frame = cvQueryFrame(ob->readerAvi);
            if(ob->i == 0)
            {
                ob->myTool->FirstModel(ob->frame);
	        continue;
            }
            ob->mask = ob->myTool->ProcessFrame(ob->i,frame,mask);
            ob->background = ob->myTool->ShowBackground();

            Thread^ Threadtwo = gcnew Thread(gcnew ParameterizedThreadStart(&ThreadProc2));
            Threadtwo->Start(formViewer);

      }
 }

Of course the compiler says, that (line 16) 'formViewer' : undeclared identifier

So, how can i give the Thread 2 objects, or what is generally wrong??
Yes, that is my very first project mit threads, and I don't understand completely all about that.

Thanks in advance
Only one thread can own a window handle. From worker thread SendMessage() and let be processed in your main message loop.
Topic archived. No new replies allowed.