我试图将2个变量从MainForm中的一个线程传递到另一个表单,但是这样做会发生错误.
private void TrackingThread( )
{
float targetX = 0;
float targetY = 0;
while ( true )
{
camera1Acquired.WaitOne( );
camera2Acquired.WaitOne( );
lock ( this )
{
// stop the thread if it was signaled
if ( ( x1 == -1 ) && ( y1 == -1 ) && ( x2 == -1 ) && ( y2 == -1 ) )
{
break;
}
// get middle point
targetX = ( x1 + x2 ) / 2;
targetY = …Run Code Online (Sandbox Code Playgroud)