Guest User

Untitled

a guest
Aug 17th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. Exception handler not being invoked
  2. public partial class Window1 : Window
  3. {
  4. public Window1()
  5. {
  6. InitializeComponent();
  7. }
  8.  
  9. private void button1_Click(object sender, RoutedEventArgs e)
  10. {
  11. new Thread(() =>
  12. {
  13. Dispatcher.CurrentDispatcher.UnhandledExceptionFilter += Dispatcher_UnhandledExceptionFilter;
  14. doer();
  15. }).Start();
  16. }
  17. void Dispatcher_UnhandledExceptionFilter(
  18. object sender,
  19. DispatcherUnhandledExceptionFilterEventArgs e)
  20. {
  21. MessageBox.Show("FILTER REACHED");
  22. }
  23.  
  24.  
  25. private void doer()
  26. {
  27. throw new NotImplementedException();
  28. }
  29. }
  30.  
  31. new Thread(() =>
  32. {
  33. Dispatcher.CurrentDispatcher.UnhandledExceptionFilter += Dispatcher_UnhandledExceptionFilter;
  34. Dispatcher.Invoke(new Action(()=>doer()));
  35. }).Start();
  36.  
  37. new Thread(() =>
  38. {
  39. Dispatcher.CurrentDispatcher.UnhandledExceptionFilter += Dispatcher_UnhandledExceptionFilter;
  40. Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Normal, new ThreadStart(delegate
  41. {
  42. doer();
  43. }));
  44. }).Start();
Add Comment
Please, Sign In to add comment