本文整理汇总了C#中ProgressMonitor.EndTask方法的典型用法代码示例。如果您正苦于以下问题:C# ProgressMonitor.EndTask方法的具体用法?C# ProgressMonitor.EndTask怎么用?C# ProgressMonitor.EndTask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgressMonitor
的用法示例。
在下文中一共展示了ProgressMonitor.EndTask方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: execute
public PushResult execute(ProgressMonitor monitor)
{
monitor.BeginTask(PROGRESS_OPENING_CONNECTION, -1);
connection = transport.openPush();
try
{
monitor.EndTask();
Dictionary<string, RemoteRefUpdate> preprocessed = prepareRemoteUpdates();
if (transport.DryRun)
modifyUpdatesForDryRun();
else if (preprocessed.Count != 0)
connection.Push(monitor, preprocessed);
}
finally
{
connection.Close();
}
if (!transport.DryRun)
updateTrackingRefs();
return prepareOperationResult();
}
示例2: execute
/// <summary>
/// Perform push operation between local and remote repository - set remote
/// refs appropriately, send needed objects and update local tracking refs.
/// <para />
/// When <seealso cref="Transport.DryRun"/> is true, result of this operation is
/// just estimation of real operation result, no real action is performed.
/// </summary>
/// <param name="monitor">
/// Progress monitor used for feedback about operation.
/// </param>
/// <returns> result of push operation with complete status description. </returns>
/// <exception cref="NotSupportedException">
/// When push operation is not supported by provided transport.
/// </exception>
/// <exception cref="TransportException">
/// When some error occurred during operation, like I/O, protocol
/// error, or local database consistency error.
/// </exception>
public PushResult execute(ProgressMonitor monitor)
{
if (monitor == null)
throw new ArgumentNullException("monitor");
monitor.BeginTask(PROGRESS_OPENING_CONNECTION, ProgressMonitor.UNKNOWN);
_connection = _transport.openPush();
try
{
monitor.EndTask();
IDictionary<string, RemoteRefUpdate> preprocessed = PrepareRemoteUpdates();
if (_transport.DryRun)
{
ModifyUpdatesForDryRun();
}
else if (preprocessed.Count != 0)
{
_connection.Push(monitor, preprocessed);
}
}
finally
{
_connection.Close();
}
if (!_transport.DryRun)
{
UpdateTrackingRefs();
}
return PrepareOperationResult();
}
示例3: OpenIndex
public void OpenIndex(ProgressMonitor pm)
{
if (Index != null) return;
try
{
Index = PackIndex.Open(TmpIdx);
return;
}
catch (FileNotFoundException)
{
}
Stream s = _connection.open("pack/" + _idxName);
pm.BeginTask("Get " + _idxName.Slice(0, 12) + "..idx", s.Length < 0 ? -1 : (int)(s.Length / 1024));
try
{
var fos = new FileStream(TmpIdx.ToString(), System.IO.FileMode.Open, FileAccess.ReadWrite);
try
{
var buf = new byte[2048];
int cnt;
while (!pm.IsCancelled && (cnt = s.Read(buf, 0, buf.Length)) >= 0)
{
fos.Write(buf, 0, cnt);
pm.Update(cnt / 1024);
}
}
finally
{
fos.Close();
}
}
catch (IOException)
{
TmpIdx.Delete();
throw;
}
finally
{
s.Close();
}
pm.EndTask();
if (pm.IsCancelled)
{
TmpIdx.Delete();
return;
}
try
{
Index = PackIndex.Open(TmpIdx);
}
catch (IOException)
{
TmpIdx.Delete();
throw;
}
}
示例4: ExpandOneAlternate
private List<WalkRemoteObjectDatabase> ExpandOneAlternate(AnyObjectId id, ProgressMonitor pm)
{
while (_noAlternatesYet.Count > 0)
{
WalkRemoteObjectDatabase wrr = _noAlternatesYet.First.Value;
_noAlternatesYet.RemoveFirst();
try
{
pm.BeginTask("Listing alternates", ProgressMonitor.UNKNOWN);
List<WalkRemoteObjectDatabase> altList = wrr.getAlternates();
if (altList != null && altList.Count > 0)
return altList;
}
catch (IOException e)
{
RecordError(id, e);
}
finally
{
pm.EndTask();
}
}
return null;
}
示例5: DownloadObject
private void DownloadObject(ProgressMonitor pm, AnyObjectId id)
{
if (_local.HasObject(id)) return;
while (true)
{
if (DownloadPackedObject(pm, id))
return;
string idStr = id.Name;
string subdir = idStr.Slice(0, 2);
string file = idStr.Substring(2);
string looseName = subdir + "/" + file;
for (int i = _lastRemoteIdx; i < _remotes.Count; i++)
{
if (DownloadLooseObject(id, looseName, _remotes[i]))
{
_lastRemoteIdx = i;
return;
}
}
for (int i = 0; i < _lastRemoteIdx; i++)
{
if (DownloadLooseObject(id, looseName, _remotes[i]))
{
_lastRemoteIdx = i;
return;
}
}
while (_noPacksYet.Count > 0)
{
WalkRemoteObjectDatabase wrr = _noPacksYet.First.Value;
_noPacksYet.RemoveFirst();
List<string> packNameList;
try
{
pm.BeginTask("Listing packs", ProgressMonitor.UNKNOWN);
packNameList = wrr.getPackNames();
}
catch (IOException e)
{
RecordError(id, e);
continue;
}
finally
{
pm.EndTask();
}
if (packNameList == null || packNameList.Count == 0)
continue;
foreach (string packName in packNameList)
{
if (!_packsConsidered.Contains(packName))
{
_packsConsidered.Add(packName);
_unfetchedPacks.AddLast(new RemotePack(_lockMessage, _packLocks, _objCheck, _local, wrr, packName));
}
}
if (DownloadPackedObject(pm, id))
return;
}
List<WalkRemoteObjectDatabase> al = ExpandOneAlternate(id, pm);
if (al != null && al.Count > 0)
{
foreach (WalkRemoteObjectDatabase alt in al)
{
_remotes.Add(alt);
_noPacksYet.AddLast(alt);
_noAlternatesYet.AddLast(alt);
}
continue;
}
List<Exception> failures = null;
if (_fetchErrors.ContainsKey(id.Copy()))
{
failures = _fetchErrors[id.Copy()];
}
TransportException te = null;
if (failures != null && failures.Count > 0)
{
te = failures.Count == 1 ?
new TransportException("Cannot get " + id.Name + ".", failures[0]) :
new TransportException("Cannot get " + id.Name + ".", new CompoundException(failures));
}
if (te == null)
{
te = new TransportException("Cannot get " + id.Name + ".");
}
throw te;
}
}
示例6: ResolveDeltas
private void ResolveDeltas(ProgressMonitor progress)
{
progress.BeginTask(PROGRESS_RESOLVE_DELTA, _deltaCount);
int last = _entryCount;
for (int i = 0; i < last; i++)
{
int before = _entryCount;
ResolveDeltas(_entries[i]);
progress.Update(_entryCount - before);
if (progress.IsCancelled)
{
throw new IOException("Download cancelled during indexing");
}
}
progress.EndTask();
}
示例7: index
public void index(ProgressMonitor progress)
{
progress.Start(2 /* tasks */);
try
{
try
{
ReadPackHeader();
_entries = new PackedObjectInfo[(int)_objectCount];
_baseById = new ObjectIdSubclassMap<DeltaChain>();
_baseByPos = new LongMap<UnresolvedDelta>();
progress.BeginTask(PROGRESS_DOWNLOAD, (int)_objectCount);
for (int done = 0; done < _objectCount; done++)
{
IndexOneObject();
progress.Update(1);
if (progress.IsCancelled)
{
throw new IOException("Download cancelled");
}
}
ReadPackFooter();
EndInput();
progress.EndTask();
if (_deltaCount > 0)
{
if (_packOut == null)
{
throw new IOException("need packOut");
}
ResolveDeltas(progress);
if (_entryCount < _objectCount)
{
if (!_fixThin)
{
throw new IOException("pack has " + (_objectCount - _entryCount) + " unresolved deltas");
}
FixThinPack(progress);
}
}
if (_packOut != null && (_keepEmpty || _entryCount > 0))
{
_packOut.Flush();
}
_packDigest = null;
_baseById = null;
_baseByPos = null;
if (_dstIdx != null && (_keepEmpty || _entryCount > 0))
{
WriteIdx();
}
}
finally
{
try
{
InflaterCache.Instance.release(_inflater);
}
finally
{
_inflater = null;
}
_windowCursor = WindowCursor.Release(_windowCursor);
progress.EndTask();
if (_packOut != null)
{
_packOut.Close();
}
}
if (_keepEmpty || _entryCount > 0)
{
if (_dstPack != null)
{
_dstPack.IsReadOnly = true;
}
if (_dstIdx != null)
{
_dstIdx.IsReadOnly = true;
}
}
}
catch (IOException)
{
if (_dstPack != null) _dstPack.Delete();
if (_dstIdx != null) _dstIdx.Delete();
throw;
}
}
示例8: OpenIndex
public void OpenIndex(ProgressMonitor pm)
{
if (Index != null) return;
if (TmpIdx.IsFile())
{
try
{
Index = PackIndex.Open(TmpIdx);
return;
}
catch (FileNotFoundException)
{
// Fall through and get the file.
}
}
using (Stream s = _connection.open("pack/" + _idxName))
{
pm.BeginTask("Get " + _idxName.Slice(0, 12) + "..idx", !s.CanSeek ? ProgressMonitor.UNKNOWN : (int)(s.Length / 1024));
try
{
using (var fos = new FileStream(TmpIdx.FullName, System.IO.FileMode.CreateNew, FileAccess.Write))
{
var buf = new byte[2048];
int cnt;
while (!pm.IsCancelled && (cnt = s.Read(buf, 0, buf.Length)) > 0)
{
fos.Write(buf, 0, cnt);
pm.Update(cnt / 1024);
}
}
}
catch (IOException)
{
TmpIdx.DeleteFile();
throw;
}
}
pm.EndTask();
if (pm.IsCancelled)
{
TmpIdx.DeleteFile();
return;
}
try
{
Index = PackIndex.Open(TmpIdx);
}
catch (IOException)
{
TmpIdx.DeleteFile();
throw;
}
}
示例9: DownloadObject
private void DownloadObject(ProgressMonitor pm, AnyObjectId id)
{
if (_local.HasObject(id)) return;
while (true)
{
// Try a pack file we know about, but don't have yet. Odds are
// that if it has this object, it has others related to it so
// getting the pack is a good bet.
//
if (DownloadPackedObject(pm, id))
return;
// Search for a loose object over all alternates, starting
// from the one we last successfully located an object through.
//
string idStr = id.Name;
string subdir = idStr.Slice(0, 2);
string file = idStr.Substring(2);
string looseName = subdir + "/" + file;
for (int i = _lastRemoteIdx; i < _remotes.Count; i++)
{
if (DownloadLooseObject(id, looseName, _remotes[i]))
{
_lastRemoteIdx = i;
return;
}
}
for (int i = 0; i < _lastRemoteIdx; i++)
{
if (DownloadLooseObject(id, looseName, _remotes[i]))
{
_lastRemoteIdx = i;
return;
}
}
// Try to obtain more pack information and search those.
//
while (_noPacksYet.Count > 0)
{
WalkRemoteObjectDatabase wrr = _noPacksYet.First.Value;
_noPacksYet.RemoveFirst();
ICollection<string> packNameList;
try
{
pm.BeginTask("Listing packs", ProgressMonitor.UNKNOWN);
packNameList = wrr.getPackNames();
}
catch (IOException e)
{
// Try another repository.
//
RecordError(id, e);
continue;
}
finally
{
pm.EndTask();
}
if (packNameList == null || packNameList.Count == 0)
continue;
foreach (string packName in packNameList)
{
bool contains = _packsConsidered.Contains(packName);
_packsConsidered.Add(packName);
if (!contains)
{
_unfetchedPacks.AddLast(new RemotePack(_lockMessage, _packLocks, _objCheck, _local, wrr, packName));
}
}
if (DownloadPackedObject(pm, id))
return;
}
// Try to expand the first alternate we haven't expanded yet.
//
ICollection<WalkRemoteObjectDatabase> al = ExpandOneAlternate(id, pm);
if (al != null && al.Count > 0)
{
foreach (WalkRemoteObjectDatabase alt in al)
{
_remotes.Add(alt);
_noPacksYet.AddLast(alt);
_noAlternatesYet.AddLast(alt);
}
continue;
}
// We could not obtain the object. There may be reasons why.
//
List<Exception> failures = _fetchErrors.get(id.Copy());
var te = new TransportException("Cannot get " + id.Name + ".");
if (failures != null && failures.Count > 0)
{
//.........这里部分代码省略.........