일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- MSSQL
- PYTHON MSSQL
- oracle
- 장고
- 자본주의
- M2M
- matplot
- pymssql
- 윈도우10
- MSSQL PYTHON
- rs422
- 파이썬
- 크롤링
- Python
- 오라클
- 티스토리 초대장
- Serial
- 텐서플로우
- vscode
- django
- 딥러닝
- MX Component
- sql developer
- scrapy
- rs485
- Visual Studio Code
- c#
- windows10
- MEAN Stack
- tensorflow
Archives
- Today
- Total
안까먹을라고 쓰는 블로그
[C#] 프로그램 재시작 소스 본문
반응형
네트워크 문제인지,, PLC 문제인지,, 정상통신이 되다가 PLC와의 통신이 안되는 문제가 있음..
프로그램 재시작 체크
PLC와 통신을 해서 해당 어드레스를 읽으면,, Count를 계속 상승시키는데,, 이게 설정한 시간동안 같으면
프로그램을 재시작하도록 처리
// PLCReadCount가 계속 같으면 프로그램 리스타트
if (Convert.ToInt32(lblCnt.Text) == GV.PLCBeforeCnt)
{
// 2020.10.14 Debug
label5.Text = GV.PLCBeforeCnt.ToString();
// 5분동안 같으면 프로그램 재시작
// 2020.10.14 Debug
// if (GV.PLCBeforeCnt > 300) Program_Restart();
// 2020.10.19 dz
// if (GV.PLCBeforeCnt > 30) Program_Restart();
if (GV.PLCBeforeCnt > GV.PLCFailLimitSecond) Program_Restart();
GV.PLCFailCnt += 1;
}
else GV.PLCFailCnt = 0;
프로그램 재시작 함수
private void Program_Restart()
{
try
{
GV.Fnc.WriteLog("RestartLog", "[Program_Restart]");
Application.Exit();
System.Threading.Thread.Sleep(1000);
// Case 1
//Application.Restart();
// Case 2
System.Diagnostics.Process.Start(Application.ExecutablePath);
}
catch (Exception Ex)
{
GV.Fnc.WriteLog("ExLog", "[Program_Restart] - Ex : " + Ex.ToString());
}
}
반응형
Comments