系统.穿线. ThreadAbortEx ... [英] System. Threading. ThreadAbortEx...

查看:58
本文介绍了系统.穿线. ThreadAbortEx ...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此代码显示启动画面.但它抛出ThreadabortException.它不会显示stacktrace.请帮助我如何处理此异常.

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.

public void splashscreen()
      {

      Application.Run(new Form13());

      }









 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:

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



启用JIT调试后,任何未处理的异常
将被发送到计算机上注册的JIT调试器
而不是由此对话框处理.



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.

推荐答案

Google怎么样?
请参见 http://msdn.microsoft. com/en-us/library/system.threading.threadabortexception(v = vs.100).aspx [ [/EDIT]

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


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


第一个:因为您调用了Abort方法,所以启动了ThreadAbortException.
第二:也许中止后没有堆栈跟踪.

不要打电话给Abort.

您可以通过启动计时器并在500毫秒后关闭自身来将延迟放在Form13中,以避免中止.否则,您必须忍受该异常并忽略它!

如果您的程序仅在关闭form13之后才能继续执行,则不需要作为线程启动它,那么最好使用计时器(参见上文).

HTH
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


尝试一下:
Try this:
public void splashscreen()
{
    try {
      Application.Run(new Form13());
    } catch {}
}


Maxim.


Maxim.


这篇关于系统.穿线. ThreadAbortEx ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆