本文整理汇总了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);
}
示例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;
}
示例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);
}
}