Esempio n. 1
0
        private static void StopGlobalQueuedExecutionService()
        {
            lock (_globalQueuedExecutionServices.SyncRoot)
            {
                foreach (string name in _globalQueuedExecutionServices.ToKeysArray())
                {
                    if (ChoTraceSwitch.Switch.TraceVerbose)
                    {
                        Trace.WriteLine("Stopping {0} Q execution service...".FormatString(name));
                    }

                    try
                    {
                        _globalQueuedExecutionServices[name].Dispose();
                    }
                    catch (ThreadAbortException)
                    {
                        Thread.ResetAbort();
                    }
                    catch (Exception)
                    {
                    }
                }

                _globalQueuedExecutionServices.Clear();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Called when the <see cref="AppDomain.DomainUnload"/> event fires
        /// </summary>
        /// <param name="sender">the <see cref="AppDomain"/> that is exiting</param>
        /// <param name="e">null</param>
        /// <remarks>
        /// <para>
        /// Called when the <see cref="AppDomain.DomainUnload"/> event fires.
        /// </para>
        /// <para>
        /// When the event is triggered the log4net system is <see cref="Shutdown()"/>.
        /// </para>
        /// </remarks>
        private static void OnDomainUnload(object sender, EventArgs e)
        {
            Thread.Sleep(1000);  //TODO: To be parameterized

            foreach (Type type in _onDomainUnloadHandlers.ToKeysArray())
            {
                foreach (MethodInfo methodInfo in _onDomainUnloadHandlers[type])
                {
                    if (ChoTrace.ChoSwitch.TraceVerbose)
                    {
                        ChoTrace.Info(ChoType.GetMemberAttribute <ChoAppDomainUnloadMethodAttribute>(methodInfo).Description);
                    }

                    //using (ChoBufferProfileEx profile = new ChoBufferProfileEx(ChoType.GetMemberAttribute<ChoAppDomainUnloadMethodAttribute>(methodInfo).Description))
                    //{
                    try
                    {
                        ChoType.InvokeMethod(type, methodInfo.Name, null);
                    }
                    catch (Exception ex)
                    {
                        //profile.Append(ex);
                    }
                    //}
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Called when the <see cref="AppDomain.DomainUnload"/> event fires
        /// </summary>
        /// <param name="sender">the <see cref="AppDomain"/> that is exiting</param>
        /// <param name="e">null</param>
        /// <remarks>
        /// <para>
        /// Called when the <see cref="AppDomain.DomainUnload"/> event fires.
        /// </para>
        /// <para>
        /// When the event is triggered the log4net system is <see cref="Shutdown()"/>.
        /// </para>
        /// </remarks>
        private static void OnDomainUnload(object sender, EventArgs e)
        {
            if (ChoFramework.ShutdownRequested)
            {
                return;
            }

            ChoFramework.ShutdownRequested = true;

            if (_shutdownCompleted)
            {
                return;
            }

            try
            {
                Thread.Sleep(1000);  //TODO: To be parameterized

                foreach (Type type in _onDomainUnloadHandlers.ToKeysArray())
                {
                    foreach (MethodInfo methodInfo in _onDomainUnloadHandlers[type])
                    {
                        if (ChoTraceSwitch.Switch.TraceVerbose)
                        {
                            Trace.WriteLine(ChoType.GetMemberAttribute <ChoAppDomainUnloadMethodAttribute>(methodInfo).Description);
                        }
                        //ChoTrace.Info(ChoType.GetMemberAttribute<ChoAppDomainUnloadMethodAttribute>(methodInfo).Description);

                        //using (ChoBufferProfileEx profile = new ChoBufferProfileEx(ChoType.GetMemberAttribute<ChoAppDomainUnloadMethodAttribute>(methodInfo).Description))
                        //{
                        try
                        {
                            ChoType.InvokeMethod(type, methodInfo.Name, null);
                        }
                        catch (Exception) // ex)
                        {
                            //profile.Append(ex);
                        }
                        //}
                    }
                }

                //if (ChoApplication.ApplicationMode == ChoApplicationMode.Console)
                //    ChoFramework.Shutdown();
            }
            finally
            {
                try
                {
                    ChoTrace.FlushAll();
                }
                catch { }
                _shutdownCompleted = true;
            }
        }
Esempio n. 4
0
        private static void StopGlobalQueuedExecutionService()
        {
            lock (_globalQueuedExecutionServices.SyncRoot)
            {
                foreach (string name in _globalQueuedExecutionServices.ToKeysArray())
                {
                    if (ChoTrace.ChoSwitch.TraceVerbose)
                    {
                        Trace.WriteLine("Stopping {0} execution service...".FormatString(name));
                    }
                    _globalQueuedExecutionServices[name].Dispose();
                }

                _globalQueuedExecutionServices.Clear();
            }
        }
Esempio n. 5
0
 private static void OnAssemblyLoad(object sender, AssemblyLoadEventArgs args)
 {
     foreach (Type type in _onDomainLoadHandlers.ToKeysArray())
     {
         foreach (MethodInfo methodInfo in _onDomainLoadHandlers[type])
         {
             using (ChoBufferProfileEx profile = new ChoBufferProfileEx(ChoType.GetMemberAttribute <ChoAppDomainLoadMethodAttribute>(methodInfo).Description))
             {
                 try
                 {
                     ChoType.InvokeMethod(type, methodInfo.Name, null);
                 }
                 catch (Exception ex)
                 {
                     profile.Append(ex);
                 }
             }
         }
     }
 }