【发布时间】:2015-09-21 20:03:50
【问题描述】:
我有通过 rs232 连接重量的 Windows-Mobile 程序。
它的工作非常好,但是如果程序在一段时间内工作 -
字体是单独从大字体变为小字体
我注意到问题出在第一部分 - 如果我标记这部分 1
字体不会改变。 (我不知道为什么会这样……)
我的代码:
//PART 1
port = new SerialPort("COM3", 9600, Parity.None, 8, StopBits.One);
port.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(Recepcion);
private SerialPort port;
StringBuilder SB;
private void Recepcion(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
try
{
SB = new StringBuilder(1000);
Application.DoEvents();
System.Threading.Thread.Sleep(122);
SB.Append(port.ReadExisting());
port.DiscardInBuffer();
this.Invoke(new EventHandler(Actualizar));
}
catch { }
}
//PART2
string MOMO1, MOMO2;
string[] WI;
string ALL;
private void Actualizar(object s, EventArgs e)
{
ALL = SB.ToString().Trim();
WI = ALL.Split(',');
ALL = WI[2].ToString().Trim();
MOMO1 = ALL.Replace("+", "").Replace("g", "").Replace("ST", "").Replace("GS", "").Replace("US", "");
if (MOMO1 != "")
{
MOMO2 = MOMO1;
}
lblMSG.Font = new Font("Ariel", 48, FontStyle.Bold);
lblMSG.Text = MOMO2;
Check_Weight();
GC.Collect(); // <-- is it OK ?
}
谁能告诉我为什么以及如何解决它?
【问题讨论】:
-
Check_Weight() 中发生了什么?
-
嗨,在 Check_Weight() 中 - 非常简单的方法 - 没有意义
-
嗨,我更新了我的问题。
标签: c# serial-port windows-mobile windows-ce