コード例 #1
0
        private static TimeoutHandle _internal_setTimeout(Action TheAction, int Timeout, bool invokeOnGuiThread, Form formForInvoking, Action <Exception> ReportException)
        {
            if (Timeout < 0)
            {
                Timeout = 0;
            }
            TimeoutHandle cancelHandle = new TimeoutHandle();

            if (invokeOnGuiThread && Timeout == 0)
            {
                if (!formForInvoking.IsDisposed)
                {
                    formForInvoking.Invoke(TheAction);
                }
            }
            else
            {
                Thread t = new Thread(
                    () =>
                {
                    try
                    {
                        if (cancelHandle.Wait(Timeout))
                        {
                            return;
                        }
                        if (invokeOnGuiThread)
                        {
                            if (!formForInvoking.IsDisposed)
                            {
                                formForInvoking.Invoke(TheAction);
                            }
                        }
                        else
                        {
                            TheAction();
                        }
                    }
                    catch (ThreadAbortException) { throw; }
                    catch (Exception ex)
                    {
                        if (ReportException != null)
                        {
                            ReportException(ex);
                        }
                        else
                        {
                            Logger.Debug(ex);
                        }
                    }
                }
                    );
                t.Name         = "Timeout";
                t.IsBackground = true;
                t.Start();
            }
            return(cancelHandle);
        }
コード例 #2
0
ファイル: Window.cs プロジェクト: hallvar/Joddes.CS
		public void ClearTimeout (TimeoutHandle handle)
		{
		}