Results 1 to 19 of 19

Thread: Not executing SplashScreenThread [RESOLVED] :D

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Thumbs up Not executing SplashScreenThread [RESOLVED] :D

    OK, so far I am using the following code to terminate my program:

    VB Code:
    1. End
    2. ' Damn that was hard to code :D

    Anyway, after the command is executed, it hangs and wont finnish closing the application. It never used to do that before, and just suddenly started off now. This is the error I am getting:

    An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll

    The only thing I did, was add a Class that allows me to play sound files, and add 10 forms. And it worked fine the day I did that, but today I find this error. So, I'm trying to think of a solution, and I think what would happen if I terminate the application by forcing to end the main thread or whatever... Like VB.NET ends my application by pressing the STOP button, which is what I have to do.
    Last edited by martw; May 12th, 2005 at 03:39 PM. Reason: Resolved

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: How to terminate an application...

    Hi,

    If you used a form as the startup object then when you close that form the application will exit.

    If you used "Application.Run(frmsomething)" in the Sub main of the module, then you need

    Appplication.Exit
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: How to terminate an application...

    Yeah, I use that for my splash screen. I just tried that and I get the same error.

    Blah... This debug stuff doesn't help me at all... I can't even break the code thats causing it!

  4. #4
    Lively Member milkmood's Avatar
    Join Date
    Mar 2005
    Location
    Forests of Delta Halo
    Posts
    109

    Re: How to terminate an application...

    VB Code:
    1. Me.Close()
    That's the first thing I learned. That might only work when you have a single form though.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: How to terminate an application...

    Nope. But I tried to exit the program in the bin folder. (Running it in windows) and it works fine... But now I think that my splash screen may have something to do with it, because now, it just appears for a split second and vanishes! I'll keep you posted. Thanks for the replies.

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: How to terminate an application...

    Quote Originally Posted by martw
    Yeah, I use that for my splash screen. I just tried that and I get the same error.

    Blah... This debug stuff doesn't help me at all... I can't even break the code thats causing it!

    Sorry. Don't understand you. What is the startup object? If it is the splash form, how do you create the instance of the next form, etc.?

    If it is the Sub Main, post your module code.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  7. #7
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: How to terminate an application...

    Quote Originally Posted by milkmood
    VB Code:
    1. Me.Close()
    That's the first thing I learned. That might only work when you have a single form though.

    That works provided the form represented by ME was the startup object of the project. It will close the application no matter how many forms are running - provided you can reach that code (which you won't if one of the open forms was opened with ShowDialog() )
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: How to terminate an application...

    Quote Originally Posted by taxes
    Sorry. Don't understand you. What is the startup object? If it is the splash form, how do you create the instance of the next form, etc.?

    If it is the Sub Main, post your module code.
    OK, the Splash Screen is the startup object. That screen then closes and I can then use another screen as the Parent.

    Now a new problem. Can anyone tell me a little about classes? My splash screen is a little destroyed, appearing only a split second before the MainForm. I would like to try and do this:

    I have a Folder Group called "Modules" with a Module called MainModule which gives threading priorty to the Splash Screen Amongst other things and a Class called SoundPlayer which plays sounds. I would like to keep the Class from being executed untill MainForm loads after the SplashScreen so the Class isn't executed while the Module is. Is it possible to do this? Because I think that the class is somehow conflicting with the Module at runtime. If anyone has any ideas, please help.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: How to terminate an application...

    Why is this happening?

    The thread 'SplashScreenThread' (0xf78) has exited with code 0 (0x0).

    It shouldn't do that, because then there isn't the simulated 7 second startup. I will post my module code up:

    VB Code:
    1. Public Sub Main(ByVal args() As String)
    2.         Dim SplashScreenThread As Threading.Thread
    3.         SplashScreenThread = New System.Threading.Thread(AddressOf SplashScreen.ShowSplashScreen)
    4.         SplashScreenThread.ApartmentState = Threading.ApartmentState.STA
    5.         SplashScreenThread.Name = "SplashScreenThread"
    6.         SplashScreenThread.Priority = Threading.ThreadPriority.Highest
    7.         SplashScreenThread.Start()
    8.         ' Remains inactive for 7 seconds to simulate delayed startup
    9.         System.Threading.Thread.Sleep(7000)
    10.         '----------------------------------------------------------------
    11.         Application.Run(New FormMain)
    12.         ' Seperately activates FormMain so that SplashScreen can be
    13.         ' terminated without exiting the application.
    14.     End Sub

    Well, now you know the thread process. But what could make it end @ without executing the remainder of the code?

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: Not executing SplashScreenThread (Formerly: How to terminate an application...)

    After changing the sleep time to 1000 and 20000, I found that it does execute the thread but its not showing the splash screen and its also not appearing in the taskbar when I make it show. I didn't make any recent changes to the code that has anythign to do with the Splash Screen, but apparently something had to happen.

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: Not executing SplashScreenThread (Formerly: How to terminate an application...)

    OK, I tried stepping through the code to find the source of the problem. After I found that it skipped a line, I stepped back and then it showed the Splash Screen. Now it won't show the FormMain after the 7 seconds. I have to manually close the SplashScreen (Alt+F4) so it closes the SplashScreen and then displays the MainForm AFTER exactly 7 seconds after the Splash Screen disappears! This is weird and I haven't the slightest clue what could be causing these problems. Any help appreciated.

  12. #12
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: Not executing SplashScreenThread (Formerly: How to terminate an application...)

    Hi

    I don't understand what is happening to this thread. Posts seem to be dissapearing!!!

    Anyway, You don't need to have the Splash form in a different thread and, by the way your Splash form is NOT your startup object. Your startup object is Sub main in the module.

    Why not try something like, in the Module

    VB Code:
    1. Dim frmSplash As New fclsSplash
    2. Dim frmMain As New fclsMain
    3.  
    4. Public Sub Main()
    5. FrmSplash.ShowDialog()
    6. Application.Run(frmMain)
    7. End Sub

    Then in fclsSplash put the following code in the Activated event

    VB Code:
    1. Threading.Thread.Sleep(7000)
    2. Me.Close
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: Not executing SplashScreenThread (Formerly: How to terminate an application...)

    Your startup object is Sub main in the module.
    Bah, how stupid of me, your right. Oh and what does fcls stand for? This doesn't bother me, but I'm just curious...

    Oh, thanks for the code. I will check it out as soon as I can
    I never know what to put in this section...



    So sue me... ... ... I'm just kidding...


    www.fat-pie.com Flash Movies... You gotta see 'em to believe 'em!

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: Not executing SplashScreenThread (Formerly: How to terminate an application...)

    Nope, the Splash remains and doesn't close. This is really getting on me, as I never changed the code for the Splash Screen to begin with and it used to work fine!
    I never know what to put in this section...



    So sue me... ... ... I'm just kidding...


    www.fat-pie.com Flash Movies... You gotta see 'em to believe 'em!

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: Not executing SplashScreenThread (Formerly: How to terminate an application...)

    Now I get this error on the line which says "SplashForm.ShowDialog()"

    An unhandled exception of type 'System.ObjectDisposedException' occurred in system.windows.forms.dll

    Additional information: Cannot access a disposed object named "SplashScreen".
    I never know what to put in this section...



    So sue me... ... ... I'm just kidding...


    www.fat-pie.com Flash Movies... You gotta see 'em to believe 'em!

  16. #16
    New Member
    Join Date
    Mar 2005
    Posts
    9

    Re: Not executing SplashScreenThread (Formerly: How to terminate an application...)

    visual basic code:--------------------------------------------------------------------------------
    'make sure the topmost property of the splash form is True

    [Highlight=VB]
    Dim frmSplash As New fclsSplash
    Dim frmMain As New fclsMain

    Public Sub Main()
    FrmSplash.Show()
    Application.Run(frmMain)
    End Sub

    'place a timer on your splash form with the desired wait time.
    'close the splash form when the timer fires

  17. #17

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Thumbs up Re: Not executing SplashScreenThread (Formerly: How to terminate an application...)

    VB Code:
    1. Public Sub Main()
    2.         SplashForm.Show()
    3.         Application.DoEvents()
    4.         ' Remains inactive for 7 seconds to simulate delayed startup
    5.         System.Threading.Thread.Sleep(7000)
    6.         SplashForm.Close()
    7.         Application.Run(MainForm)
    8.         Exit Sub
    9.     End Sub

    Yeah! Thank you all who helped me, but this code solves the problem. I maintained all of my other code which is in SplashScreen.vb (The form) so all the extra stuff there is fine. Thanls again to all who helped me
    I never know what to put in this section...



    So sue me... ... ... I'm just kidding...


    www.fat-pie.com Flash Movies... You gotta see 'em to believe 'em!

  18. #18
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: Not executing SplashScreenThread (Formerly: How to terminate an application...)

    Quote Originally Posted by martw
    Bah, how stupid of me, your right. Oh and what does fcls stand for? This doesn't bother me, but I'm just curious...

    Oh, thanks for the code. I will check it out as soon as I can

    Hi,
    Standard practice is to use the prefix "fcls" for all the Forms you design. It is short for "formclass". Then when you create the instance you can use

    Dim frmMain As New fclsMain

    and it is easier to follow your code.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  19. #19

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: Not executing SplashScreenThread [RESOLVED] :D

    Well, I still use the old frm prefix form VB6. Mainly becuase I'm used to it. Thanks
    I never know what to put in this section...



    So sue me... ... ... I'm just kidding...


    www.fat-pie.com Flash Movies... You gotta see 'em to believe 'em!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width