コード例 #1
0
        protected override void OnStart(string[] args)
        {
            Thread.MemoryBarrier();
            var agent = _agent;
            Thread.MemoryBarrier();

            if (agent == null)
            {
                //this.TraceData(TraceEventType.Information, "TMailAgent OnStarting ..");
                WriteDebugLine("OnStarting ..");
                agent = new TMailService();
                agent.OnWriteLine += new LineWriterDelegate(agent_OnWriteLine);
                if (Interlocked.CompareExchange(ref _agent, agent, null) == null)
                {
                    //WriteLine("OnStart Begin");
                    //this.TraceData(TraceEventType.Information, "TMailAgent OnStart Begin");
                    WriteDebugLine("PerformStart Begin");
                    PerfromStart(agent);
                    WriteDebugLine("PerformStart Done");
                    //this.TraceData(TraceEventType.Information, "TMailAgentService started");
                }
                //this.TraceData(TraceEventType.Information, "TMailAgent OnStart Completed ..");
            }
        }
コード例 #2
0
        private static void PerformStart()
        {
            Thread.MemoryBarrier();
            var svc = __agent;
            Thread.MemoryBarrier();

            if (svc == null)
            {
                svc = new TMailService();
                if (Interlocked.CompareExchange(ref __agent, svc, null) == null)
                {
                    svc.StartAgentLogic((s, t) =>
                        {
                            svc.OnWriteLine += OnWriteLine;
                            OnWriteLine(s, "Agent service started");
                        });
                }
            }
        }
コード例 #3
0
		/// <summary> 
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			components = new System.ComponentModel.Container();
			this.ServiceName = String.Concat("TMail Agent v", Assembly.GetExecutingAssembly().GetName().Version);
			this._agent = null;
		}
コード例 #4
0
        private void PerfromStart(TMailService agent)
        {
            try
            {
                //this.TraceData(TraceEventType.Information, "TMailAgent PerformStarting ..");
                WriteDebugLine("PerformStart Begin..");
                //this.LogInfo("TMailAgent PerformStarting ..");
                agent.StartAgentLogic(null);
                 WriteDebugLine("PerformStart Done..");
                //this.TraceData(TraceEventType.Information, "TMailAgent PerformStarted ..");
                //this.LogInfo("TMailAgent PerformStarted ..");

            }
            catch (Exception ex)
            {
                //this.TraceData(TraceEventType.Information, "TMailAgent failed to PerformStart: {0}", ex.Message);
                //this.LogInfo("TMailAgent failed to PerformStart: {0}",ex.Message);
                //this.TraceData(TraceEventType.Error, "Unexpected Error In PerformStart", ex.FormatForLogging());
                YPMon.Critical("TMailAgentService", "Unexpected Error In PerformStart", ex.FormatForLogging());
                throw;
            }
        }