C# 字体正在以一种奇怪的方式单独改变-Windows CE
我有一个Windows Mobile程序,可以通过rs232连接重量 它的工作非常出色,但如果该计划在一段时间内有效- 字体正在从大字体变为小字体 我注意到问题出现在第一部分1-如果我标记这部分1 字体不会改变。(我不知道为什么会发生这种情况……) 我的代码:C# 字体正在以一种奇怪的方式单独改变-Windows CE,c#,serial-port,windows-mobile,windows-ce,C#,Serial Port,Windows Mobile,Windows Ce,我有一个Windows Mobile程序,可以通过rs232连接重量 它的工作非常出色,但如果该计划在一段时间内有效- 字体正在从大字体变为小字体 我注意到问题出现在第一部分1-如果我标记这部分1 字体不会改变。(我不知道为什么会发生这种情况……) 我的代码: //PART 1 port = new SerialPort("COM3", 9600, Parity.None, 8, StopBits.One); port.DataReceived += new System.I
//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 ?
}
//第1部分
端口=新的串行端口(“COM3”,9600,奇偶校验。无,8,停止位。1);
port.DataReceived+=新系统.IO.Ports.SerialDataReceivedEventHandler(Recepcion);
专用串行端口;
为某人做准备;
私有无效接收(对象发送方,System.IO.Ports.SerialDataReceivedEventArgs e)
{
尝试
{
SB=新的StringBuilder(1000);
Application.DoEvents();
系统线程线程睡眠(122);
SB.Append(port.ReadExisting());
port.DiscardInBuffer();
调用(新事件处理程序(Actualizar));
}
捕获{}
}
//第二部分
字符串MOMO1,MOMO2;
字符串[]WI;
串全部;
私有void实现(对象s、事件参数e)
{
ALL=SB.ToString().Trim();
WI=ALL.Split(',');
ALL=WI[2].ToString().Trim();
MOMO1=ALL.Replace(“+”,”).Replace(“+”,”).Replace(“'ST“,”).Replace('GS“,”).Replace('US“,”);
如果(MOMO1!=“”)
{
momoo2=MOMO1;
}
lblMSG.Font=新字体(“Ariel”,48,FontStyle.Bold);
lblMSG.Text=MOMO2;
检查重量();
GC.Collect();//在代码中尝试此方法
private SerialPort port;
StringBuilder SB;
private void Recepcion(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
try
{
SB = new StringBuilder(1000);
SB.Append(port.ReadLine());
port.DiscardInBuffer();
this.Invoke(new EventHandler(Actualizar));
}
catch { }
}
在Check_Weight()中发生了什么?嗨,在Check_Weight()中-是一个非常简单的方法-没有意义。嗨,我更新了我的问题。