C#两个类之间变量的变化(串口调用的时候出现了问题) 这个是我的串口打开之后出现的问题,我从另一个类中调用这个类的close事件,结果这个类的串口竟然出现了NULL这个改变不太清楚发生了什么,希望有人能回答下。我觉得不爽之后决定直接在这个类中直接进行serialport关闭行为,出现了上面这种错误有人能告诉我该怎么改吗c#串口 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你直接调用close事件,能保证port肯定不为空吗,肯定创建了吗 我出现的问题就是直接调用之后出现了port变为空了。不知道怎么改了。 先判断端口的状态,如果是OPEN 则关闭 你能讲细点嘛?我出的问题就像版主说的port改变之后成了NULL,原来是有串口的 我有截图的,第一个是打开,第二个是过程中,第三个是返回到那个类调用中的时候出现了问题,变成了NULL。 private void buttonEtt_Click(object sender, EventArgs e) { ETT985Form newForm = new ETT985Form(); this.Hide(); newForm.Show(); }这个是我的调用界面的button,但是按了之后没到ETT985到了waitform这个界面,是为什么?这个界面就是显示了一个等待界面。 public static void showWaitForm(Form form) { if (formPlaseWait != null) MessageBox.Show("NOT NULL showWaitForm"); form.Invoke((MethodInvoker)delegate { formPlaseWait = new FormPleaseWait(); formPlaseWait.ShowDialog(form); }); }这个是因为委托吗?我就是这个看不懂所以不知道程序到底怎么运行,所以没办法修改。帮帮忙感激不净,如果有什么需要了解的请说 rs232Module.Open(sPorts[i], 4800, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One)public bool Open(String strCommNo, int nBaud, Parity parity, int bits, StopBits stopBits) { if (strCommNo == null || strCommNo.Length == 0) return false; if (m_CommPort != null && m_CommPort.IsOpen) return true; m_CommPort = new SerialPort(strCommNo, nBaud, parity, bits, stopBits); m_CommPort.Handshake = Handshake.None; //m_CommPort.ReadTimeout = 5000; try { m_CommPort.Open(); Console.WriteLine("COMM Port " + strCommNo + " is open"); } catch { Console.WriteLine("!!! Error COMM Port " + strCommNo); return false; } return true; }这个上面是打开端口,那么我要关闭窗口怎么弄啊?窗口一直没法关 问个很奇怪的数字筛选问题 C# 内存问题如何解决. datagrid怎么禁止调整宽度 在继承接口的类中,为什么重写接口的方法中不能使用此类的全局变量呀? 一直为空!!!!!感谢大家! 怎样用C#做一个为静态图片添加字的软件 arcgis engine 如何把数据库查询以后获得属性列比较之后,把同sql表中的另外一个属性列输出来~~?? SET协议中的认证中心和支付网关系统实现的源代码 谢谢了 很急 .net构架下的软件开发,寻找创业伙伴! 程序发布问题 winform数据绑定小问题 请教关于鼠标特效的问题
{
ETT985Form newForm = new ETT985Form();
this.Hide();
newForm.Show();
}
这个是我的调用界面的button,但是按了之后没到ETT985到了waitform这个界面,是为什么?这个界面就是显示了一个等待界面。
public static void showWaitForm(Form form)
{
if (formPlaseWait != null)
MessageBox.Show("NOT NULL showWaitForm");
form.Invoke((MethodInvoker)delegate
{
formPlaseWait = new FormPleaseWait();
formPlaseWait.ShowDialog(form);
});
}
这个是因为委托吗?我就是这个看不懂所以不知道程序到底怎么运行,所以没办法修改。帮帮忙感激不净,如果有什么需要了解的请说
public bool Open(String strCommNo, int nBaud, Parity parity, int bits, StopBits stopBits)
{
if (strCommNo == null || strCommNo.Length == 0)
return false; if (m_CommPort != null && m_CommPort.IsOpen)
return true; m_CommPort = new SerialPort(strCommNo, nBaud, parity, bits, stopBits);
m_CommPort.Handshake = Handshake.None;
//m_CommPort.ReadTimeout = 5000; try
{
m_CommPort.Open();
Console.WriteLine("COMM Port " + strCommNo + " is open");
}
catch
{
Console.WriteLine("!!! Error COMM Port " + strCommNo);
return false;
}
return true;
}
这个上面是打开端口,那么我要关闭窗口怎么弄啊?窗口一直没法关