簡體   English   中英

修改其他類的線程屬性

[英]Modify an attribute of a thread from other class

我的代碼有問題。 我有2節課:

  • 短信
  • clsWorker

當線程運行時,我想從clsSMS類中修改它們的屬性。

public class clsSMS
{
    clsWorker objclsWorker;

     public clsSMS(clsWorker objclsWorker = null)
    {
          this.objclsWorker.operatorBlocageError38();
          // The above call doesn't work...
          // I think the objclsWorker  is always null...
          // What do you think?
    }
}


public class clsWorker
{
    public clsSMS clsobjSMS;

    public clsWorker(...)
    {
          this.clsobjSMS = new clsSMS(objclsWorker: this);

    }
    public void operatorBlocageError38(/*String port_concerne, bool erreur38*/)
    {
        MessageBox.Show("The method call work fine!");
    }
}

您實例化過clsWorker的發布代碼中沒有顯示該代碼。

clsWorker worker = new clsWorker();
worker.operatorBlocageError38();

如果在實例化之前調用operatorBlocageError38,則該方法必須標記為靜態。

public static void operatorBlocageError38()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM