本文整理汇总了C#中MonoDevelop.Core.ProgressMonitor.EndTask方法的典型用法代码示例。如果您正苦于以下问题:C# ProgressMonitor.EndTask方法的具体用法?C# ProgressMonitor.EndTask怎么用?C# ProgressMonitor.EndTask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoDevelop.Core.ProgressMonitor
的用法示例。
在下文中一共展示了ProgressMonitor.EndTask方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteFile
public Task WriteFile (string file, object obj, bool saveProjects, ProgressMonitor monitor)
{
return Task.Run (delegate {
Solution sol = (Solution)obj;
try {
monitor.BeginTask (GettextCatalog.GetString ("Saving solution: {0}", file), 1);
WriteFileInternal (file, file, sol, saveProjects, monitor);
} catch (Exception ex) {
monitor.ReportError (GettextCatalog.GetString ("Could not save solution: {0}", file), ex);
LoggingService.LogError (GettextCatalog.GetString ("Could not save solution: {0}", file), ex);
throw;
} finally {
monitor.EndTask ();
}
});
}
示例2: ReadWorkspaceItemFile
WorkspaceItem ReadWorkspaceItemFile (FilePath fileName, ProgressMonitor monitor)
{
XmlTextReader reader = new XmlTextReader (new StreamReader (fileName));
try {
monitor.BeginTask (string.Format (GettextCatalog.GetString ("Loading workspace item: {0}"), fileName), 1);
reader.MoveToContent ();
XmlDataSerializer ser = new XmlDataSerializer (MD1ProjectService.DataContext);
ser.SerializationContext.BaseFile = fileName;
ser.SerializationContext.ProgressMonitor = monitor;
WorkspaceItem entry = (WorkspaceItem)ser.Deserialize (reader, typeof(WorkspaceItem));
entry.FileName = fileName;
return entry;
} catch (Exception ex) {
monitor.ReportError (string.Format (GettextCatalog.GetString ("Could not load solution item: {0}"), fileName), ex);
throw;
} finally {
monitor.EndTask ();
reader.Close ();
}
}
示例3: InstallEntry
void InstallEntry (ProgressMonitor monitor, DeployContext ctx, SolutionFolderItem entry, ConfigurationSelector configuration)
{
foreach (DeployFile df in DeployService.GetDeployFiles (ctx, new SolutionFolderItem[] { entry }, configuration)) {
string targetPath = df.ResolvedTargetFile;
if (targetPath == null) {
monitor.ReportWarning ("Could not copy file '" + df.RelativeTargetPath + "': Unknown target directory.");
continue;
}
CopyFile (monitor, df.SourcePath, df.ResolvedTargetFile, df.FileAttributes);
}
SolutionFolder c = entry as SolutionFolder;
if (c != null) {
monitor.BeginTask ("Installing solution '" + c.Name + "'", c.Items.Count);
foreach (SolutionFolderItem ce in c.Items) {
InstallEntry (monitor, ctx, ce, configuration);
monitor.Step (1);
}
monitor.EndTask ();
}
}
示例4: ValidateWellFormedness
/// <summary>
/// Checks that the xml in this view is well-formed.
/// </summary>
public static XmlDocument ValidateWellFormedness (ProgressMonitor monitor, string xml, string fileName)
{
monitor.BeginTask (GettextCatalog.GetString ("Validating XML..."), 1);
bool error = false;
XmlDocument doc = null;
try {
doc = new XmlDocument ();
doc.LoadXml (xml);
} catch (XmlException ex) {
monitor.ReportError (ex.Message, ex);
AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskSeverity.Error);
error = true;
}
if (error) {
monitor.Log.WriteLine (GettextCatalog.GetString ("Validation failed."));
TaskService.ShowErrors ();
} else {
monitor.Log.WriteLine (GettextCatalog.GetString ("XML is valid."));
}
monitor.EndTask ();
return error? null: doc;
}
示例5: ValidateXml
/// <summary>
/// Validates the xml against known schemas.
/// </summary>
public static XmlDocument ValidateXml (ProgressMonitor monitor, string xml, string fileName)
{
monitor.BeginTask (GettextCatalog.GetString ("Validating XML..."), 1);
bool error = false;
XmlDocument doc = null;
StringReader stringReader = new StringReader (xml);
XmlReaderSettings settings = new XmlReaderSettings ();
settings.ValidationFlags = XmlSchemaValidationFlags.ProcessIdentityConstraints
| XmlSchemaValidationFlags.ProcessInlineSchema
| XmlSchemaValidationFlags.ProcessSchemaLocation
| XmlSchemaValidationFlags.ReportValidationWarnings;
settings.ValidationType = ValidationType.Schema;
settings.DtdProcessing = DtdProcessing.Parse;
ValidationEventHandler validationHandler = delegate (object sender, System.Xml.Schema.ValidationEventArgs args) {
if (args.Severity == XmlSeverityType.Warning) {
monitor.Log.WriteLine (args.Message);
AddTask (fileName, args.Exception.Message, args.Exception.LinePosition, args.Exception.LineNumber,TaskSeverity.Warning);
} else {
AddTask (fileName, args.Exception.Message, args.Exception.LinePosition, args.Exception.LineNumber,TaskSeverity.Error);
monitor.Log.WriteLine (args.Message);
error = true;
}
};
settings.ValidationEventHandler += validationHandler;
try {
foreach (XmlSchemaCompletionData sd in XmlSchemaManager.SchemaCompletionDataItems)
settings.Schemas.Add (sd.Schema);
settings.Schemas.Compile ();
XmlReader reader = XmlReader.Create (stringReader, settings);
doc = new XmlDocument();
doc.Load (reader);
} catch (XmlSchemaException ex) {
monitor.ReportError (ex.Message, ex);
AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error);
error = true;
}
catch (XmlException ex) {
monitor.ReportError (ex.Message, ex);
AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error);
error = true;
}
finally {
if (stringReader != null)
stringReader.Dispose ();
settings.ValidationEventHandler -= validationHandler;
}
if (error) {
monitor.Log.WriteLine (GettextCatalog.GetString ("Validation failed."));
TaskService.ShowErrors ();
} else {
monitor.Log.WriteLine (GettextCatalog.GetString ("XML is valid."));
}
monitor.EndTask ();
return error? null: doc;
}
示例6: WriteFileInternal
void WriteFileInternal (string file, string sourceFile, Solution solution, bool saveProjects, ProgressMonitor monitor)
{
if (saveProjects) {
var items = solution.GetAllSolutionItems ().ToArray ();
monitor.BeginTask (items.Length + 1);
foreach (var item in items) {
try {
monitor.BeginStep ();
item.SavingSolution = true;
item.SaveAsync (monitor).Wait ();
} finally {
item.SavingSolution = false;
}
}
} else {
monitor.BeginTask (1);
monitor.BeginStep ();
}
SlnFile sln = new SlnFile ();
sln.FileName = file;
if (File.Exists (sourceFile)) {
try {
sln.Read (sourceFile);
} catch (Exception ex) {
LoggingService.LogError ("Existing solution can't be updated since it can't be read", ex);
}
}
sln.FormatVersion = format.SlnVersion;
// Don't modify the product description if it already has a value
if (string.IsNullOrEmpty (sln.ProductDescription))
sln.ProductDescription = format.ProductDescription;
solution.WriteSolution (monitor, sln);
sln.Write (file);
monitor.EndTask ();
}
示例7: OnReadProject
protected override void OnReadProject (ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject)
{
base.OnReadProject (monitor, msproject);
var ext = msproject.GetMonoDevelopProjectExtension ("MonoDevelop.Autotools.MakefileInfo");
if (ext == null)
return;
data = MakefileData.Read (ext);
if (data == null)
return;
monitor.BeginTask (GettextCatalog.GetString ("Updating project from Makefile"), 1);
try {
data.OwnerProject = Project;
if (data.SupportsIntegration)
data.UpdateProject (monitor, false);
monitor.Step (1);
} catch (Exception e) {
monitor.ReportError (GettextCatalog.GetString (
"\tError loading Makefile for project {0}", Project.Name), e);
} finally {
monitor.EndTask ();
}
}
示例8: WriteProjects
void WriteProjects (SolutionFolder folder, SlnFile sln, ProgressMonitor monitor, HashSet<string> unknownProjects)
{
monitor.BeginTask (folder.Items.Count);
foreach (SolutionFolderItem ce in folder.Items.ToArray ())
{
monitor.BeginStep ();
if (ce is SolutionItem) {
SolutionItem item = (SolutionItem) ce;
var proj = sln.Projects.GetOrCreateProject (ce.ItemId);
proj.TypeGuid = item.TypeGuid;
proj.Name = item.Name;
proj.FilePath = FileService.NormalizeRelativePath (FileService.AbsoluteToRelativePath (sln.BaseDirectory, item.FileName)).Replace ('/', '\\');
var sec = proj.Sections.GetOrCreateSection ("MonoDevelopProperties", SlnSectionType.PreProcess);
sec.SkipIfEmpty = true;
folder.ParentSolution.WriteSolutionFolderItemData (monitor, sec.Properties, ce);
if (item.ItemDependencies.Count > 0) {
sec = proj.Sections.GetOrCreateSection ("ProjectDependencies", SlnSectionType.PostProcess);
sec.Properties.ClearExcept (unknownProjects);
foreach (var dep in item.ItemDependencies)
sec.Properties.SetValue (dep.ItemId, dep.ItemId);
} else
proj.Sections.RemoveSection ("ProjectDependencies");
} else if (ce is SolutionFolder) {
var proj = sln.Projects.GetOrCreateProject (ce.ItemId);
proj.TypeGuid = MSBuildProjectService.FolderTypeGuid;
proj.Name = ce.Name;
proj.FilePath = ce.Name;
// Folder files
WriteFolderFiles (proj, (SolutionFolder) ce);
//Write custom properties
var sec = proj.Sections.GetOrCreateSection ("MonoDevelopProperties", SlnSectionType.PreProcess);
sec.SkipIfEmpty = true;
folder.ParentSolution.WriteSolutionFolderItemData (monitor, sec.Properties, ce);
}
if (ce is SolutionFolder)
WriteProjects (ce as SolutionFolder, sln, monitor, unknownProjects);
}
monitor.EndTask ();
}
示例9: LoadSolution
//.........这里部分代码省略.........
if (sol.IsSolutionItemEnabled (projectPath)) {
loadTask = Services.ProjectService.ReadSolutionItem (monitor, projectPath, format, projTypeGuid, projectGuid, ctx);
} else {
loadTask = Task.FromResult<SolutionItem> (new UnloadedSolutionItem () {
FileName = projectPath
});
}
var ft = loadTask.ContinueWith (ta => {
try {
item = ta.Result;
if (item == null)
throw new UnknownSolutionItemTypeException (projTypeGuid);
} catch (Exception cex) {
var e = UnwrapException (cex).First ();
string unsupportedMessage = e.Message;
if (e is UserException) {
var ex = (UserException) e;
LoggingService.LogError ("{0}: {1}", ex.Message, ex.Details);
monitor.ReportError (string.Format ("{0}{1}{1}{2}", ex.Message, Environment.NewLine, ex.Details), null);
} else {
LoggingService.LogError (string.Format ("Error while trying to load the project {0}", projectPath), e);
monitor.ReportWarning (GettextCatalog.GetString (
"Error while trying to load the project '{0}': {1}", projectPath, e.Message));
}
SolutionItem uitem;
uitem = new UnknownSolutionItem () {
FileName = projectPath,
LoadError = unsupportedMessage,
};
item = uitem;
item.ItemId = projectGuid;
item.TypeGuid = projTypeGuid;
}
item.UnresolvedProjectDependencies = ReadSolutionItemDependencies (sec);
// Deserialize the object
DeserializeSolutionItem (monitor, sol, item, sec);
lock (items) {
if (!items.ContainsKey (projectGuid)) {
items.Add (projectGuid, item);
} else {
monitor.ReportError (GettextCatalog.GetString ("Invalid solution file. There are two projects with the same GUID. The project {0} will be ignored.", projectPath), null);
}
}
monitor.Step (1);
});
loadTasks.Add (ft);
}
Task.WaitAll (loadTasks.ToArray ());
sol.LoadedProjects = new HashSet<string> (items.Keys);
var nested = sln.Sections.GetSection ("NestedProjects");
if (nested != null)
LoadNestedProjects (nested, items, monitor);
// Resolve project dependencies
foreach (var it in items.Values.OfType<SolutionItem> ()) {
if (it.UnresolvedProjectDependencies != null) {
foreach (var id in it.UnresolvedProjectDependencies.ToArray ()) {
SolutionFolderItem dep;
if (items.TryGetValue (id, out dep) && dep is SolutionItem) {
it.UnresolvedProjectDependencies.Remove (id);
it.ItemDependencies.Add ((SolutionItem)dep);
}
}
if (it.UnresolvedProjectDependencies.Count == 0)
it.UnresolvedProjectDependencies = null;
}
}
//Add top level folders and projects to the main folder
foreach (string id in sortedList) {
SolutionFolderItem ce;
if (items.TryGetValue (id, out ce) && ce.ParentFolder == null)
folder.Items.Add (ce);
}
//FIXME: This can be just SolutionConfiguration also!
LoadSolutionConfigurations (sln.SolutionConfigurationsSection, sol, monitor);
LoadProjectConfigurationMappings (sln.ProjectConfigurationsSection, sol, items, monitor);
foreach (var e in sln.Sections) {
string name = e.Id;
if (name.StartsWith ("MonoDevelopProperties.")) {
int i = name.IndexOf ('.');
LoadMonoDevelopConfigurationProperties (name.Substring (i+1), e, sol, monitor);
}
}
monitor.EndTask ();
}
示例10: OnCheckoutProgress
static void OnCheckoutProgress (int completedSteps, int totalSteps, ProgressMonitor monitor, ref int progress)
{
if (progress == 0 && completedSteps == 0) {
monitor.BeginTask ("Checking out files", totalSteps);
throttleWatch.Restart ();
}
int steps = completedSteps - progress;
if (throttleWatch.ElapsedMilliseconds > progressThrottle) {
monitor.Step (steps);
throttleWatch.Restart ();
}
progress = completedSteps;
if (completedSteps >= totalSteps) {
monitor.EndTask ();
throttleWatch.Stop ();
}
}
示例11: UpdateCompleted
static bool UpdateCompleted (ProgressMonitor monitor,
ProjectFile file, ProjectFile genFile, SingleFileCustomToolResult result,
bool runMultipleFiles)
{
monitor.EndTask ();
if (monitor.CancellationToken.IsCancellationRequested) {
monitor.ReportError (GettextCatalog.GetString ("Cancelled"), null);
monitor.Dispose ();
return false;
}
string genFileName;
try {
bool broken = false;
if (result.UnhandledException != null) {
broken = true;
string msg = GettextCatalog.GetString ("The '{0}' code generator crashed", file.Generator);
result.Errors.Add (new CompilerError (file.Name, 0, 0, "", msg + ": " + result.UnhandledException.Message));
monitor.ReportError (msg, result.UnhandledException);
LoggingService.LogError (msg, result.UnhandledException);
}
genFileName = result.GeneratedFilePath.IsNullOrEmpty?
null : result.GeneratedFilePath.ToRelative (file.FilePath.ParentDirectory);
if (!string.IsNullOrEmpty (genFileName)) {
bool validName = genFileName.IndexOfAny (new [] { '/', '\\' }) < 0
&& FileService.IsValidFileName (genFileName);
if (!broken && !validName) {
broken = true;
string msg = GettextCatalog.GetString ("The '{0}' code generator output invalid filename '{1}'",
file.Generator, result.GeneratedFilePath);
result.Errors.Add (new CompilerError (file.Name, 0, 0, "", msg));
monitor.ReportError (msg, null);
}
}
if (result.Errors.Count > 0) {
DispatchService.GuiDispatch (delegate {
foreach (CompilerError err in result.Errors)
TaskService.Errors.Add (new TaskListEntry (file.FilePath, err.ErrorText, err.Column, err.Line,
err.IsWarning? TaskSeverity.Warning : TaskSeverity.Error,
TaskPriority.Normal, file.Project.ParentSolution, file));
});
}
if (broken)
return true;
if (!runMultipleFiles) {
if (result.Success)
monitor.ReportSuccess ("Generated file successfully.");
else if (result.SuccessWithWarnings)
monitor.ReportSuccess ("Warnings in file generation.");
else
monitor.ReportError ("Errors in file generation.", null);
}
} finally {
if (!runMultipleFiles)
monitor.Dispose ();
}
if (result.GeneratedFilePath.IsNullOrEmpty || !File.Exists (result.GeneratedFilePath))
return true;
// broadcast a change event so text editors etc reload the file
FileService.NotifyFileChanged (result.GeneratedFilePath);
// add file to project, update file properties, etc
Gtk.Application.Invoke (async delegate {
bool projectChanged = false;
if (genFile == null) {
genFile = file.Project.AddFile (result.GeneratedFilePath, result.OverrideBuildAction);
projectChanged = true;
} else if (result.GeneratedFilePath != genFile.FilePath) {
genFile.Name = result.GeneratedFilePath;
projectChanged = true;
}
if (file.LastGenOutput != genFileName) {
file.LastGenOutput = genFileName;
projectChanged = true;
}
if (genFile.DependsOn != file.FilePath.FileName) {
genFile.DependsOn = file.FilePath.FileName;
projectChanged = true;
}
if (projectChanged)
await IdeApp.ProjectOperations.SaveAsync (file.Project);
});
return true;
}
示例12: OnMoveDirectory
protected override void OnMoveDirectory (FilePath localSrcPath, FilePath localDestPath, bool force, ProgressMonitor monitor)
{
VersionInfo[] versionedFiles = GetDirectoryVersionInfo (localSrcPath, false, true);
base.OnMoveDirectory (localSrcPath, localDestPath, force, monitor);
monitor.BeginTask ("Moving files", versionedFiles.Length);
foreach (VersionInfo vif in versionedFiles) {
if (vif.IsDirectory)
continue;
FilePath newDestPath = vif.LocalPath.ToRelative (localSrcPath).ToAbsolute (localDestPath);
Add (newDestPath, false, monitor);
monitor.Step (1);
}
monitor.EndTask ();
}
示例13: OnTransferProgress
static bool OnTransferProgress (TransferProgress tp, ProgressMonitor monitor, ref int progress)
{
if (progress == 0 && tp.ReceivedObjects == 0) {
monitor.BeginTask ("Receiving and indexing objects", 2 * tp.TotalObjects);
throttleWatch.Restart ();
}
int currentProgress = tp.ReceivedObjects + tp.IndexedObjects;
int steps = currentProgress - progress;
if (throttleWatch.ElapsedMilliseconds > progressThrottle) {
monitor.Step (steps);
throttleWatch.Restart ();
}
progress = currentProgress;
if (tp.IndexedObjects >= tp.TotalObjects) {
monitor.EndTask ();
throttleWatch.Stop ();
}
return !monitor.CancellationToken.IsCancellationRequested;
}
示例14: NotifyFileChanges
void NotifyFileChanges (ProgressMonitor monitor, TreeChanges statusList)
{
// Files added to source branch not present to target branch.
var removed = statusList.Where (c => c.Status == ChangeKind.Added).Select (c => GetRepository (c.Path).FromGitPath (c.Path)).ToList ();
var modified = statusList.Where (c => c.Status != ChangeKind.Added).Select (c => GetRepository (c.Path).FromGitPath (c.Path)).ToList ();
monitor.BeginTask (GettextCatalog.GetString ("Updating solution"), removed.Count + modified.Count);
FileService.NotifyFilesChanged (modified, true);
monitor.Step (modified.Count);
FileService.NotifyFilesRemoved (removed);
monitor.Step (removed.Count);
monitor.EndTask ();
}
示例15: SwitchToBranch
public bool SwitchToBranch (ProgressMonitor monitor, string branch)
{
Signature sig = GetSignature ();
Stash stash;
int stashIndex = -1;
if (sig == null)
return false;
monitor.BeginTask (GettextCatalog.GetString ("Switching to branch {0}", branch), GitService.StashUnstashWhenSwitchingBranches ? 4 : 2);
// Get a list of files that are different in the target branch
var statusList = GitUtil.GetChangedFiles (RootRepository, branch);
if (GitService.StashUnstashWhenSwitchingBranches) {
// Remove the stash for this branch, if exists
string currentBranch = GetCurrentBranch ();
stashIndex = GetStashForBranch (RootRepository.Stashes, currentBranch);
if (stashIndex != -1)
RootRepository.Stashes.Remove (stashIndex);
if (!TryCreateStash (monitor, GetStashName (currentBranch), out stash))
return false;
monitor.Step (1);
}
try {
int progress = 0;
RootRepository.Checkout (branch, new CheckoutOptions {
OnCheckoutProgress = (path, completedSteps, totalSteps) => OnCheckoutProgress (completedSteps, totalSteps, monitor, ref progress),
OnCheckoutNotify = RefreshFile,
CheckoutNotifyFlags = refreshFlags,
});
} finally {
// Restore the branch stash
if (GitService.StashUnstashWhenSwitchingBranches) {
stashIndex = GetStashForBranch (RootRepository.Stashes, branch);
if (stashIndex != -1)
PopStash (monitor, stashIndex);
monitor.Step (1);
}
}
// Notify file changes
NotifyFileChanges (monitor, statusList);
BranchSelectionChanged?.Invoke (this, EventArgs.Empty);
monitor.EndTask ();
return true;
}