fonts are Changing alone in a strange way - Windows CE , i update my first question
-
i have Windows-Mobile program that work with weight Connecting through rs232. its work excellent, but If the program works in a period of time - fonts are Changing alone from big to small font I noticed that the problem is in the first part 1 - if i mark this part1 The fonts will not change. (I have no idea why this is happening....) my code: //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 ? } Can anyone advise me why and how to solve it ?
-
i have Windows-Mobile program that work with weight Connecting through rs232. its work excellent, but If the program works in a period of time - fonts are Changing alone from big to small font I noticed that the problem is in the first part 1 - if i mark this part1 The fonts will not change. (I have no idea why this is happening....) my code: //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 ? } Can anyone advise me why and how to solve it ?
I refer the gentleman to my reply to his question earlier today[^] - which I see he has ignored completely... Is there any point in asking questions if you are going to ignore the answers?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
I refer the gentleman to my reply to his question earlier today[^] - which I see he has ignored completely... Is there any point in asking questions if you are going to ignore the answers?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
Clearly, you haven't tried very hard - given that over 5 hours later, the code is still exactly the same...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
i have Windows-Mobile program that work with weight Connecting through rs232. its work excellent, but If the program works in a period of time - fonts are Changing alone from big to small font I noticed that the problem is in the first part 1 - if i mark this part1 The fonts will not change. (I have no idea why this is happening....) my code: //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 ? } Can anyone advise me why and how to solve it ?
This is still bad code - it looks to be exactly the same as the one you posted earlier. To add to OG's earlier comments - Application.DoEvents followed by a Thread.Sleep - this tells me you are trying to force it to wait for data and hoping that you will magically sync with the data. Oh, and you shouldn't have an empty catch statement - you have no idea what exceptions you are catching and throwing away.