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


C# IProgressStatus.Cancel方法代码示例

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


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

示例1: RunScannerProcess

        void RunScannerProcess(IProgressStatus monitor)
        {
            ISetupHandler setup = GetSetupHandler ();

            IProgressStatus scanMonitor = monitor;
            ArrayList pparams = new ArrayList ();

            bool retry = false;
            do {
                try {
                    if (monitor.LogLevel > 1)
                        monitor.Log ("Looking for addins");
                    setup.Scan (scanMonitor, registry, null, (string[]) pparams.ToArray (typeof(string)));
                    retry = false;
                }
                catch (Exception ex) {
                    ProcessFailedException pex = ex as ProcessFailedException;
                    if (pex != null) {
                        // Get the last logged operation.
                        if (pex.LastLog.StartsWith ("scan:")) {
                            // It crashed while scanning a file. Add the file to the ignore list and try again.
                            string file = pex.LastLog.Substring (5);
                            pparams.Add (file);
                            monitor.ReportWarning ("Could not scan file: " + file);
                            retry = true;
                            continue;
                        }
                    }
                    fatalDatabseError = true;
                    // If the process has crashed, try to do a new scan, this time using verbose log,
                    // to give the user more information about the origin of the crash.
                    if (pex != null && !retry) {
                        monitor.ReportError ("Add-in scan operation failed. The runtime may have encountered an error while trying to load an assembly.", null);
                        if (monitor.LogLevel <= 1) {
                            // Re-scan again using verbose log, to make it easy to find the origin of the error.
                            retry = true;
                            scanMonitor = new ConsoleProgressStatus (true);
                        }
                    } else
                        retry = false;

                    if (!retry) {
                        var pfex = ex as ProcessFailedException;
                        monitor.ReportError ("Add-in scan operation failed", pfex != null? pfex.InnerException : ex);
                        monitor.Cancel ();
                        return;
                    }
                }
            }
            while (retry);
        }
开发者ID:mono,项目名称:mono-addins,代码行数:51,代码来源:AddinDatabase.cs

示例2: DatabaseInfrastructureCheck

		bool DatabaseInfrastructureCheck (IProgressStatus monitor)
		{
			// Do some sanity check, to make sure the basic database infrastructure can be created
			
			bool hasChanges = false;
			
			try {
			
				if (!Directory.Exists (AddinCachePath)) {
					Directory.CreateDirectory (AddinCachePath);
					hasChanges = true;
				}
			
				if (!Directory.Exists (AddinFolderCachePath)) {
					Directory.CreateDirectory (AddinFolderCachePath);
					hasChanges = true;
				}
			
				// Make sure we can write in those folders

				Util.CheckWrittableFloder (AddinCachePath);
				Util.CheckWrittableFloder (AddinFolderCachePath);
				
				fatalDatabseError = false;
			}
			catch (Exception ex) {
				monitor.ReportError ("Add-in cache directory could not be created", ex);
				fatalDatabseError = true;
				monitor.Cancel ();
			}
			return hasChanges;
		}
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:32,代码来源:AddinDatabase.cs

示例3: MonitorProcessStatus

		public static void MonitorProcessStatus (IProgressStatus monitor, TextReader reader, StringCollection progessLog)
		{
			string line;
			string exceptionText = null;
			while ((line = reader.ReadLine ()) != null) {
				int i = line.IndexOf (':');
				if (i != -1) {
					string tag = line.Substring (0, i);
					string txt = line.Substring (i+1);
					bool wasTag = true;
					
					switch (tag) {
						case "process-ps-msg":
							monitor.SetMessage (Decode (txt));
							break;
						case "process-ps-progress":
							monitor.SetProgress (double.Parse (txt));
							break;
						case "process-ps-log":
							monitor.Log (Decode (txt));
							break;
						case "process-ps-warning":
							monitor.ReportWarning (Decode (txt));
							break;
						case "process-ps-exception":
							exceptionText = Decode (txt);
							if (exceptionText == string.Empty)
								exceptionText = null;
							break;
						case "process-ps-error":
							string err = Decode (txt);
							if (err == string.Empty) err = null;
							monitor.ReportError (err, exceptionText != null ? new Exception (exceptionText) : null);
							break;
						case "process-ps-cancel":
							monitor.Cancel ();
							break;
						case "process-ps-plog":
							progessLog.Add (Decode (txt));
							break;
						default:
							wasTag = false;
							break;
					}
					if (wasTag)
						continue;
				}
				Console.WriteLine (line);
			}
		}
开发者ID:wanglehui,项目名称:mono-addins,代码行数:50,代码来源:ProcessProgressStatus.cs


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