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


C# ICore.GetJobStatus方法代码示例

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


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

示例1: Main


//.........这里部分代码省略.........
            NetNamedPipeBinding npb = new NetNamedPipeBinding();
            npb.OpenTimeout = npb.CloseTimeout = npb.SendTimeout = npb.ReceiveTimeout = timeoutPeriod;
            npb.TransferMode = TransferMode.Buffered;
            npb.MaxReceivedMessageSize = npb.MaxBufferPoolSize = npb.MaxBufferSize = Int32.MaxValue;
            npb.ReaderQuotas = XmlDictionaryReaderQuotas.Max;
            ServiceEndpoint namedPipeEndpoint = _host.AddServiceEndpoint(typeof(ICore), npb, GlobalDefs.MCEBUDDY_LOCAL_NAMED_PIPE);
            // Increase the max objects allowed in serialization channel otherwise we lose the connection when there more than 5K objects in the queue
            foreach (OperationDescription operation in namedPipeEndpoint.Contract.Operations)
            {
                DataContractSerializerOperationBehavior dataContractBehavior = operation.Behaviors[typeof(DataContractSerializerOperationBehavior)] as DataContractSerializerOperationBehavior;

                if (dataContractBehavior != null)
                    dataContractBehavior.MaxItemsInObjectGraph = Int32.MaxValue;
            }

            _host.CloseTimeout = GlobalDefs.PIPE_TIMEOUT;
            _host.Open();

            _pipeFactory = new ChannelFactory<ICore>(npb, new EndpointAddress(GlobalDefs.MCEBUDDY_LOCAL_NAMED_PIPE));
            _pipeProxy = _pipeFactory.CreateChannel();
            if (MCEBuddyConf.GlobalMCEConfig.GeneralOptions.engineRunning)
                _pipeProxy.Start();

            // Now that we are up and running
            SystemEvents.PowerModeChanged += OnPowerChange; // Register for power event changes

            ConsoleKeyInfo cki;
            Console.Title = "MCEBuddy 2.x Service Started, Press ESC to stop";
            Console.WindowHeight = 15;
            Console.WindowWidth = 80;
            int lastNumJobs = 0;
            bool Shutdown = false;
            while (!Shutdown)
            {
                if (_forceClosed)
                    return 1; // Someone forced the closure, the handler will clean up. Exit now

                if (Console.KeyAvailable)
                {
                    cki = Console.ReadKey(true);
                    if (cki.Key == ConsoleKey.Escape)
                    {
                        Log.WriteSystemEventLog("MCEBuddy engine app received user shutdown request.", EventLogEntryType.Information);
                        Shutdown = true;
                    }
                }

                try
                {
                    for (int i = 0, numJobs = _pipeProxy.NumConversionJobs(); i < numJobs; i++)
                    {
                        if (lastNumJobs != numJobs) // The number of conversion jobs has changed
                            Console.Clear(); // Clear the screen

                        string outputStr = "";
                        outputStr = "Job" + i.ToString(System.Globalization.CultureInfo.InvariantCulture);
                        JobStatus status = _pipeProxy.GetJobStatus(i);
                        if (status != null)
                        {
                            outputStr += " " + status.CurrentAction;
                            if (status.PercentageComplete > 0)
                                outputStr += " " + status.PercentageComplete.ToString("#0.0", System.Globalization.CultureInfo.InvariantCulture) + "%";
                            else if (-1 == status.PercentageComplete)
                                outputStr += " Working..."; //some processes like ReMuxSupp don't update perc

                            if (!String.IsNullOrEmpty(status.ETA))
                                outputStr += " ETA=" + status.ETA;

                            if (!String.IsNullOrEmpty(status.SourceFile))
                                outputStr += " " + Path.GetFileName(status.SourceFile);
                        }
                        else
                        {
                            outputStr += " Idle";
                        }
                        if (outputStr.Length > 78) outputStr = outputStr.Substring(0, 78);
                        Console.SetCursorPosition(0, i);
                        Console.Write(outputStr.PadRight(78));
                        lastNumJobs = _pipeProxy.NumConversionJobs();
                    }
                }
                catch (Exception) //while debugging catch Proxy Faulted state and reset it
                {
                    if (_forceClosed)
                        return 1;

                    if (Shutdown)
                        break; // we are done here

                    _pipeFactory = new ChannelFactory<ICore>(new NetNamedPipeBinding(), new EndpointAddress(GlobalDefs.MCEBUDDY_LOCAL_NAMED_PIPE));
                    _pipeProxy = _pipeFactory.CreateChannel();
                }

                System.Threading.Thread.Sleep(GlobalDefs.LOCAL_ENGINE_POLL_PERIOD);
            }

            ConsoleCloseCheck(ControlSignalType.CTRL_CLOSE_EVENT); // Gracefully shutdown the engine and restart the windows service

            return 0; // All good
        }
开发者ID:hoeness2,项目名称:mcebuddy2,代码行数:101,代码来源:Program.cs


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