0

I am facing random hang issues in my VB.Net Windows application. On profiling I found the OnUserPreferenceChanged in stack trace. In this link on SO there is workaround provided but I don't understand how to use it in my VB.Net application. Please note Application framework is enabled in my VB.Net application.

Can any one help to understand how to subscribe to this event in VB.Net winform application?

Microsoft.Win32.SystemEvents.UserPreferenceChanged += delegate { };

prem
  • 3,348
  • 1
  • 25
  • 57
  • That would be something like `AddHandler Microsoft.Win32.SystemEvents.UserPreferenceChanged, Sub() End Sub`, however I don't think that'll really solve anything. – Visual Vincent Aug 23 '17 at 14:17
  • Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup AddHandler Microsoft.Win32.SystemEvents.UserPreferenceChanged, AddressOf PreferenceChangedHandler End Sub Tried this in ApplicationEvents.vb file. Is it going to work there? – prem Aug 23 '17 at 14:36
  • I don't see why it wouldn't. `AddHandler` works anywhere. :) – Visual Vincent Aug 23 '17 at 14:45
  • Note that Hans just did a major revision of his answer and, in the process, removed the recommended workaround. – Craig Aug 23 '17 at 16:38
  • @Craig Thanks for the information. After 7 years Hans edited the answer and removed the provided workaround. Just before I am trying to use the workaround. Still I will go with the workaround for now as I don't have enough time for a proper code cleanup. – prem Aug 24 '17 at 06:03
  • @VisualVincent Thanks for your help. It worked for me. For verifying I have set a message box to appear on this event and it worked successfully without any hang issue. Now suppressed that message box for actual release build. – prem Aug 25 '17 at 09:15

0 Answers0