0

Hello I'm stuck on the last section of my code in which I'm converting from standard VB to VB WPF I was originally using invoke commands but I'm struggling to use them within VB WPF. Currently I'm on the final two lines but I just can't seem to figure out how to rewrite it, could you possibly help?

 If Me.InvokeRequired Then
        Me.Invoke(New MethodInvoker(AddressOf AccessPicture))

I'm using VB WPF

james
  • 303
  • 1
  • 2
  • 14

1 Answers1

0

You can know if invocation is required by checking if the current thread is the UI thread and then invoke the dispatcher thread if it's required here I give you an example in c# and it's totally the same logic in VB

public void EventHandler(object object,EventArgs e)
{
if (this.Dispatcher.Thread != System.Threading.Thread.CurrentThread)
{
 // invoke using this.Dispatcher.Invoke(new EventHandler(EventHandler),object,e)
}
else
{
   //execute your code
} 
}
Ahmad Alloush
  • 141
  • 1
  • 5