开发者

Problem with multi threaded / invocation:(

开发者 https://www.devze.com 2023-02-05 23:35 出处:网络
i have 2 script 1- Soket.cs (Soket Server Working with thread) FormMain.cs(Working Normal) i call a function in FormMain from soket.cs with this code :

i have 2 script 1- Soket.cs (Soket Server Working with thread) FormMain.cs(Working Normal) i call a function in FormMain from soket.cs with this code :

public void ResiveFunc(string FuncResive)
{


    string FuncName = "";
    string FuncValue = "";
    for (int i = 0; i <= 2; i++)
    {
        FuncName += FuncResive[i];
    }
    for (int j = 4; j <= FuncResive.Length - 1; j++)
    {
        FuncValue += FuncResive[j];
    }
    MessageBox.Show(FuncName);
    MessageBox.Show(FuncValue);
    if (FuncName == "TAB")
    {
        Form1 mainForm = new Form1();
        mainForm.AdverFilter(FuncValue);
    }

}

i call this AdverFilter() function in FormMain :

  public void AdverFilter(string value)
    {
        if (this.InvokeRequired)
        {

            this.BeginInvoke(new Action<string>(AdverFilter),value);
        }
        else
        {
            this.richTextBox1.Text = value;
            MessageBox.Show("AdverFilter(string value)");
            MessageBox.Show(this.richTextB开发者_如何转开发ox1.Text);
        }

    }

but its dont work!!! Messagebox show fine the value but richtextbox.text is null in GUI (after the function is ended)... please tell me how can i fix this problem...!?


send a string clone:

mainForm.AdverFilter(FuncValue.Clone());

this.BeginInvoke(new Action<string>(AdverFilter),value.Clone());
0

精彩评论

暂无评论...
验证码 换一张
取 消