Home > Net >  C # program under Windows 7 sometimes flash back
C # program under Windows 7 sometimes flash back

Time:11-19


Program on my win10 computer everything is normal, packaged into the installation package on a Windows 7 computer flash back from time to time, and don't catch any exceptions, found in the log in the above errors,
But I got a Windows 7 computer, ran nearly a month, not out of any situation, (program corresponding.net version 3.5) is non-negotiable, strives for the great god grant instruction,

CodePudding user response:

Problems of the stability of a serial port itself, may be a hardware may also be a software problem, suggest use substitution method to try the problem

CodePudding user response:

reference 1/f, guiyang horse Ma Shanfu plugging waterproof engineering professional maintenance of swimming pool response:
stability problem of a serial port itself, may be a hardware or software problems, suggest use substitution method to try the problem



Hardware, serial port and gateway are the same (I this is a serial port receive gateway data, just running locally), it will also have what concerns?

CodePudding user response:

Error message is not very clear?
A serial port in the process of reading data, accidentally closed,
try... The catch... Under the processing

CodePudding user response:

You use multi-thread parallel this should be it, if it is pure code issues could be closed in a thread in the serial port, and then again in another thread calls the serial port, such as using a serial port to send and receive data, I have encountered this problem, because I am going to do an automatic search for a serial port function, using the timer, and then the timer event close serial port (the single-step code when he ran into another thread to execute a serial port receives the data, rather than the execution of the timer event and then ran back to the original thread), and then report the abnormal of port is closed, and the abnormal frequency is very high, this should be able to capture, my solution is before using a serial port and an if (! Scom. IsOpen) {return; }, avoid this exception to crash the program, and then open loop until a serial port in then send and receive serial command,
But it also reduces the "port is shut down" the abnormal occurrence probability, still can appear this problem, just because I captured this exception so the program does not flash back, how to perfect solve I don't know,
If you can't locate this exception, that you can be in the serial port communication events, plus a try catch {} {}
But I see you in this exception report showed abnormal get_BytesToRead inside () method

CodePudding user response:

young programmers reference 4 floor small don's reply:
you use multi-thread parallel this should be it, if it is pure code issues could be closed in a thread in the serial port, and then again in another thread calls the serial port, such as using a serial port to send and receive data, I have encountered this problem, because I want to do an automatic search for a serial port function, using the timer, and then the timer event close serial port (the single-step code when he ran into another thread to perform a serial port receives the data, rather than the execution of the timer event and then ran back to the original thread), and then report the abnormal of port is closed, and the abnormal frequency is very high, this should be able to capture, my solution is before using a serial port and an if (! Scom. IsOpen) {return; }, avoid this exception to crash the program, and then open loop until a serial port in then send and receive serial command,
But it also reduces the "port is shut down" the abnormal occurrence probability, still can appear this problem, just because I captured this exception so the program does not flash back, how to perfect solve I don't know,
If you can't locate this exception, that you can be in the serial port communication events, plus a try catch {} {}
But I see you in this exception report showed abnormal get_BytesToRead () method inside it



young programmers reference 4 floor small don's reply:
you use multi-thread parallel this should be it, if it is pure code issues could be closed in a thread in the serial port, and then again in another thread calls the serial port, such as using a serial port to send and receive data, I have encountered this problem, because I want to do an automatic search for a serial port function, using the timer, and then the timer event close serial port (the single-step code when he ran into another thread to perform a serial port receives the data, rather than the execution of the timer event and then ran back to the original thread), and then report the abnormal of port is closed, and the abnormal frequency is very high, this should be able to capture, my solution is before using a serial port and an if (! Scom. IsOpen) {return; }, avoid this exception to crash the program, and then open loop until a serial port in then send and receive serial command,
But it also reduces the "port is shut down" the abnormal occurrence probability, still can appear this problem, just because I captured this exception so the program does not flash back, how to perfect solve I don't know,
If you can't locate this exception, that you can be in the serial port communication events, plus a try catch {} {}
But I see you in this exception report showed abnormal get_BytesToRead () method inside it


Is indeed a multi-threaded parallel, I also am automatic search for a serial port, but after finding the right serial ports will send instructions thread closed, then a serial port only receives the data, then decoded into the queue,
And the program is running abnormal port was closed after a period of time, this time send instruction thread has been closed, only receiving threads, so there should be no problems is before you,

CodePudding user response:

The
reference 3 floor xian_wwq response:
error message is not very clear?
A serial port in the process of reading data, accidentally closed,
try... The catch... Under the processing


You mean, capture the error, in the heart of the catch statement serial port to open? Isn't this supposed to be some take temporary solution not effect a permanent cure?

CodePudding user response:

reference 5 floor magnateSun reply:
is indeed a multi-threaded parallel, I also am searching for a serial port automatically, but after finding the right serial ports will send instructions thread closed, then a serial port only receives the data, then decoded into the queue,
And program is running after a period of time, abnormal port is closed at this time send instruction thread has been closed, only receiving threads, so there should be no problems is before you,

I am using the timer in parallel, close the serial port and then after a serial of failure to open a serial port, at this between produced unusually close to open, then the location of the exception is in scomm read (); Serial port receive commands, may be our problem is not the same, but I think as long as you are using a serial port to send and receive will be the exception, rather than say only receive or send, the method of 3 # take temporary solution not effect a permanent cure, but is also a good way to emergency

CodePudding user response:

refer to 6th floor magnateSun response:
Quote: refer to the third floor xian_wwq response:

Error message is not very clear?
A serial port in the process of reading data, accidentally closed,
try... The catch... Under the processing


You mean, capture the error, in the heart of the catch statement serial port to open? Isn't this supposed to be some take temporary solution not effect a permanent cure?

try... The catch is, indeed, not completely
But can prevent software crashes out
The correct process is:
Judge each operation condition, if the normal is sending data, if an exception is a connection, connection normal continue to follow-up operation,
In the try... Catch the state flag
  •  Tags:  
  • C#
  • Related