wpf2016. 5. 19. 14:46

전시회에서 프로그램이 죽어서 꺼지게 되면 난감하다.


그걸 방지하기 위한 꼼수로 프로그램을 잘짜면 죽지는 않겠지만


간혹가다 생기는 메모리 누수및 관리로 인해 프로그램이 죽을때도 있기에 안정장치로 설정할 수 있다.


app.xaml.cs 에서


this.DispatcherUnhandledException += App_DispatcherUnhandledException;


 private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)

        {

            Thread.Sleep(1000);

            System.Windows.Forms.Application.Restart();

            Thread.Sleep(1000);

            Process.GetCurrentProcess().Kill();

        }


컴퓨터가 빠를경우 sleep을 사용할필요가 없는데 느린경우가 있어서 썼다.

'wpf' 카테고리의 다른 글

app.config 수정 edit  (0) 2016.07.15
[WPF] IsolatedStorageManager  (0) 2016.06.08
ListBox에서 Item 스크롤 터치시 화면 전체가 움직이던 문제  (0) 2016.04.25
SoundPlayer 사용  (0) 2016.04.25
blend 디자인모드 무시  (0) 2016.04.21
Posted by 동동(이재동)