views:

27

answers:

2

What is the vb.net equivalent of the following c# code?

var thread = new Thread(() => 
    { 
        Dispatcher.CurrentDispatcher.BeginInvoke ((Action)(() => new MySplashForm().Show())); 
        Dispatcher.Run(); 
    }); 
+2  A: 

Depends on the version of VB.Net.

Version 10.0

Dim thread As New Thread(
  Sub() 
    Dispatcher.CurrentDispatcher.BeginInvoke (
      Sub() 
        Dim form = new MySplashForm()
        form.Show()
      End Sub)
    Dispatcher.Run()
  End Sub)

Version 9.0

Sub ShowForm() 
  Dim form = new MySplashForm()
  form.Show()
End Sub

Sub CreateForm()
  Dispatcher.CurrentDispatcher.BeginInvoke(AddressOf ShowForm)
  Dispatcher.Run()
End Sub

Dim thread as New Thread(AddressOf CreateForm)

I'm not 100% sure what you're trying to achieve though. You are essentially creating another thread to asynchronously show a form but then immediately forcing the asynchronous operation. It seems like it would be a lot easier to just asynchronously show via BeginInvoke and abandon the idea of creating another thread.

JaredPar
I am trying to get the splash screen to animate have the title of the application fly in etc. I abandoned the idea once I couldnt get it work and needed to move on to other parts of the code. I will give your code a try though. Thank you for the response.
Spafa9