小编kir*_*m14的帖子

使用C#将变量从线程传递到另一个表单

我试图将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)

c# multithreading winforms

2
推荐指数
1
解决办法
853
查看次数

标签 统计

c# ×1

multithreading ×1

winforms ×1