Hi All,
I ran into some trouble with the thread above, but, I found a solution...
Aperantly, while using Visual Studio 2008 such a cross thread action is considered unsafe. Anyway, the "Invoke" method can take care of that with just a few lines of code:
private void OpenGL_Start()
{
if( this.view.InvokeRequired) {
ThreadStart aDelegate = new ThreadStart(this.view.Refresh);
for( ; ; ) {
Thread.Sleep(1000);
if( !thrOpenGL.IsAlive )
return;
this.Invoke(aDelegate);
}
}
else {
for( ; ; ) { // infinity loop for rendering
Thread.Sleep(1000);
this.view.Refresh();
}
}
}
The 'if' statement check to see if the action is done on the current thread or not and uses the "invoke" when necessary.
I hope I saved someone the 60 minutes it took me... ;-)
!--removed tag-->
Enter your message below
Sign in or Join us (it's free).