当前位置: 首页>>代码示例>>C#>>正文


C# System.Timers.Timer.EndInit方法代码示例

本文整理汇总了C#中System.Timers.Timer.EndInit方法的典型用法代码示例。如果您正苦于以下问题:C# System.Timers.Timer.EndInit方法的具体用法?C# System.Timers.Timer.EndInit怎么用?C# System.Timers.Timer.EndInit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Timers.Timer的用法示例。


在下文中一共展示了System.Timers.Timer.EndInit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitMgr

        /// <summary>
        /// Initializes the manager
        /// </summary>
        /// <returns>TRUE for success; FALSE otherwise</returns>
        public bool InitMgr()
        {
            // Get the manager settings
            try
            {
                m_MgrSettings = new clsMgrSettings();
            }
            catch
            {
                // Failures are logged by clsMgrSettings
                return false;
            }

            // Update the cached manager name
            m_MgrName = m_MgrSettings.GetParam("MgrName");

            // Set up the loggers
            var logFileName = m_MgrSettings.GetParam("logfilename");

            // LogLevel is 1 to 5: 1 for Fatal errors only, 4 for Fatal, Error, Warning, and Info, and 5 for everything including Debug messages
            var debugLevel = int.Parse(m_MgrSettings.GetParam("debuglevel"));
            clsLogTools.CreateFileLogger(logFileName, debugLevel);
            var logCnStr = m_MgrSettings.GetParam("connectionstring");

            clsLogTools.CreateDbLogger(logCnStr, "SpaceManager: " + m_MgrName);

            // Make initial log entry
            var msg = "=== Started Space Manager V" + System.Windows.Forms.Application.ProductVersion + " ===== ";
            clsLogTools.WriteLog(clsLogTools.LoggerTypes.LogFile, clsLogTools.LogLevels.INFO, msg);

            // Setup the message queue
            m_MsgQueueInitSuccess = false;
            m_MsgHandler = new clsMessageHandler();
            m_MsgHandler.BrokerUri = m_MsgHandler.BrokerUri = m_MgrSettings.GetParam("MessageQueueURI");
            m_MsgHandler.CommandQueueName = m_MgrSettings.GetParam("ControlQueueName");
            m_MsgHandler.BroadcastTopicName = m_MgrSettings.GetParam("BroadcastQueueTopic");
            m_MsgHandler.StatusTopicName = m_MgrSettings.GetParam("MessageQueueTopicMgrStatus");
            m_MsgHandler.MgrSettings = m_MgrSettings;

            // Initialize the message queue
            // Start this in a separate thread so that we can abort the initialization if necessary
            InitializeMessageQueue();

            if (m_MsgQueueInitSuccess)
            {
                //Connect message handler events
                m_MsgHandler.CommandReceived += OnCommandReceived;
                m_MsgHandler.BroadcastReceived += OnBroadcastReceived;
            }

            // Setup a file watcher for the config file
            var fInfo = new FileInfo(System.Windows.Forms.Application.ExecutablePath);
            m_FileWatcher = new FileSystemWatcher();
            m_FileWatcher.BeginInit();
            m_FileWatcher.Path = fInfo.DirectoryName;
            m_FileWatcher.IncludeSubdirectories = false;
            m_FileWatcher.Filter = m_MgrSettings.GetParam("configfilename");
            m_FileWatcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size;
            m_FileWatcher.EndInit();
            m_FileWatcher.EnableRaisingEvents = true;

            // Subscribe to the file watcher Changed event
            m_FileWatcher.Changed += FileWatcherChanged;

            // Set up the tool for getting tasks
            m_Task = new clsSpaceMgrTask(m_MgrSettings);

            // Set up the status file class
            var statusFileNameLoc = Path.Combine(fInfo.DirectoryName, "Status.xml");
            m_StatusFile = new clsStatusFile(statusFileNameLoc)
            {
                //Note: Might want to put this back in someday
                //MonitorUpdateRequired += new StatusMonitorUpdateReceived(OnStatusMonitorUpdateReceived);
                LogToMsgQueue = bool.Parse(m_MgrSettings.GetParam("LogStatusToMessageQueue")),
                MgrName = m_MgrName,
                MgrStatus = EnumMgrStatus.Running
            };
            m_StatusFile.WriteStatusFile();

            // Set up the status reporting time
            m_StatusTimer = new System.Timers.Timer();
            m_StatusTimer.BeginInit();
            m_StatusTimer.Enabled = false;
            m_StatusTimer.Interval = 60000;	// 1 minute
            m_StatusTimer.EndInit();
            m_StatusTimer.Elapsed += m_StatusTimer_Elapsed;

            // Get the most recent job history
            var historyFile = Path.Combine(m_MgrSettings.GetParam("ApplicationPath"), "History.txt");
            if (File.Exists(historyFile))
            {
                try
                {
                    // Create an instance of StreamReader to read from a file.
                    // The using statement also closes the StreamReader.
                    using (var sr = new StreamReader(historyFile))
//.........这里部分代码省略.........
开发者ID:PNNL-Comp-Mass-Spec,项目名称:DMS-Space-Manager,代码行数:101,代码来源:clsMainProgram.cs


注:本文中的System.Timers.Timer.EndInit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。