Click here to Skip to main content
15,910,661 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am using this code for showing splashscreen. but it throw a ThreadabortException. it does not show stacktrace.Please help me how to handle this exception.
C#
public void splashscreen()
      {

      Application.Run(new Form13());

      }




C#
 private void Form1_Load(object sender, EventArgs e)
        {

Thread t = new Thread(new ThreadStart(splashscreen));

               try
               {
                t.Start();
                Thread.Sleep(500);
               t.Abort();
               }
               catch(Exception e)
               {
               }
}


Exception is:
************** Exception Text **************
System.Threading.ThreadAbortException: Thread was being aborted.
   at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
   at System.Windows.Forms.Control.DefWndProc(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5456 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
PC PROTECTION PRO
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///F:/19%20oct/14%20sep%20new/PC%20PROTECTION%20PRO/PC%20PROTECTION%20PRO/bin/Debug/PC%20PROTECTION%20PRO.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5460 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5456 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5462 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Accessibility
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
Interop.Shell32
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///F:/19%20oct/14%20sep%20new/PC%20PROTECTION%20PRO/PC%20PROTECTION%20PRO/bin/Debug/Interop.Shell32.DLL
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.


For example:

HTML
<configuration>
    <system.windows.forms jitdebugging="true" />
</configuration>


When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
Posted
Updated 29-Oct-12 0:44am
v2

How about Google?
See the Remarks section in http://msdn.microsoft.com/en-us/library/system.threading.threadabortexception(v=vs.100).aspx[^].

[EDIT]
This is a special CLR exception that is implicitly rethrown (unless told differently). The Remarks section of the above mentioned link is very clear on that and the Example section shows how to deal with it. Please note that if you tweak with that, that you know what you do, otherwise you may produce a zombie process.
[/EDIT]

Cheers
Andi
 
Share this answer
 
v2
1st: A ThreadAbortException is initiated, because you called the Abort method.
2nd: There is no stack trace after an abort, maybe.

Do not call Abort.

You can put the delay in your Form13, by starting a timer and close itself after 500ms, to avoid the abort. Otherwise you must live with the exception and ignore it!

If your programm will continue only after closing your form13, you do not need to start this as a thread, then a timer (see above) is the best way.

HTH
 
Share this answer
 
v6
Comments
pradeep rasara 29-Oct-12 5:27am    
How to resolve it.what i have to do .please help me.......
.what i have to use in place of Abort.
BlackMilan 29-Oct-12 5:42am    
I don't know what you want to achieve. A thread must not be aborted in any case, it can also end by leaving the method (splashscreen() in your code)
pradeep rasara 29-Oct-12 5:52am    
I just want to stop splashscreen i.e new Form13();
BlackMilan 29-Oct-12 6:04am    
You can put the delay in your Form13, by strating a timer and close itself after 500ms, to avoid the abort. Otherwise you must live with the exception and ignore it!
Andreas Gieriet 29-Oct-12 6:34am    
You may consider using the splash screen from CP Article Yet Another Splash Screen in C# - or at least check how it is done there.
Cheers
Andi
Try this:
C#
public void splashscreen()
{
    try {
      Application.Run(new Form13());
    } catch {}
}

Maxim.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900