[英]Modify an attribute of a thread from other class
我的代码有问题。 我有2节课:
当线程运行时,我想从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.