PDA

Click to See Complete Forum and Search --> : Not Supported Exception in Threading


gRob_AndDerSon
Aug 6th, 2007, 02:15 AM
Hi there peeps, shaggy, and other members

Question:
How can I use threading in my applications that show the splash screen while initializing the form to be show then close the Splash Screen when its done to show the selected form

I set the start up to Sub Main. When I run my piece of code below, it
got an error when i showdialogue the selected form

Error:
Not Supported Exception
Control.Invoke ..... etcc

Here's my Long Code


Module Main

Public nextform As TemplateForm 'Inhereted Form
Public curForm As TemplateForm 'Inhereted Form
Dim splashScreen As New Wallpaper ' This is the Splash Screen Form
Dim t As Thread

Public Delegate Sub CloseSplashScreenCallback()
Public Delegate Function DeviceRegsCallback() as _
DeviceRegistrationForm
Public Delegate Function LoginCallback() As LoginForm

Sub Main()
' Upon(startup)

t = New Thread(New ThreadStart(AddressOf BackgroundProcess))
t.Start()
Application.Run(Splashscreen)

curform.ShowDialog

End Sub

Private Sub BackgroundProcess()
' Select what Form to be load
Using ta As New So_UsersDatasetTableAdapters.SO_UsersTableAdapter
If ta.CheckifExistingUser.Value = 0 Then
Dim refa As IAsyncResult = DeviceRegistrationForm.BeginInvoke(New _
DeviceRegsCallback(AddressOf CallDevRegs))
curForm = DeviceRegistrationForm.EndInvoke(refb)
Else
Dim refb As IAsyncResult = LoginForm.BeginInvoke(New _
LoginCallback(AddressOf CallLogIn))
curForm = LoginForm.EndInvoke(refb)
End If

End Using

Dim instance As CloseSplashScreenCallback = New _
CloseSplashScreenCallback (AddressOf CLoseSplashScreen)
splashScreen.Invoke(instance)

End Sub

Private Function CallLogIn() As LoginForm
Dim frm As New LoginForm
Return frm
End Function

Private Function CallDevRegs() As DeviceRegistrationForm
Dim frm As New DeviceRegistrationForm
Return frm
End Function

Private Sub CLoseSplashScreen()
splashScreen.Close()
End Sub

End Module



Another Question where should i place threading abort in my appz..
Hope you can help me with this. Its my problem since last Wed and until now, I can't get the solution

petevick
Aug 7th, 2007, 01:06 AM
Hi,
I think some of the functions you are using are from the full framework, hence the 'not supported' exception.

Try http://www.codeproject.com/netcf/casoast.asp or http://www.microsoft.com/downloads/details.aspx?familyid=33817CE0-B5E9-4B8E-916B-E6A381E03789&displaylang=en or http://blogs.msdn.com/davidklinems/archive/2005/08/17/452804.aspx
for samples of splash screens, both multi-threaded and normal.

You can always use a translation site to move from C# to VB

Pete

gRob_AndDerSon
Aug 7th, 2007, 01:16 AM
Peeps, thanks a lot for the references you've provided. Most of the C# to VB.Net Converter I had found on the net doesn't fully convert the code, so what I'm doing is I convert it by myself.

You know what after this project, I am planning to migrate form VB.Net to C#.Net which is good for me to start coz I have an adequate background in C/C++ and a little in java..

P.S. If you have a good references on how to Start in C# in a simple way, Kindly give it to me.

Thanks again peeps. May God be with you always