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


C# ProgressMonitor.Update方法代码示例

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


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

示例1: 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;
                }
            }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:61,代码来源:WalkFetchConnection.cs

示例2: 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();
 }
开发者ID:georgeck,项目名称:GitSharp,代码行数:16,代码来源:IndexPack.cs

示例3: writeTo

 public override void writeTo(Stream os, ProgressMonitor pm)
 {
     if (onDiskFile == null)
     {
         base.writeTo(os, pm);
         return;
     }
     if (pm == null)
         pm = NullProgressMonitor.Instance;
     using (FileStream @in = new FileStream(onDiskFile.FullName, System.IO.FileMode.Open, FileAccess.Read))
     {
         int cnt;
         byte[] buf = new byte[Block.SZ];
         while ((cnt = @in.Read(buf, 0, buf.Length)) > 0)
         {
             os.Write(buf, 0, cnt);
             pm.Update(cnt / 1024);
         }
     }
 }
开发者ID:spraints,项目名称:GitSharp,代码行数:20,代码来源:TemporaryBuffer.cs

示例4: 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;
            }
        }
开发者ID:georgeck,项目名称:GitSharp,代码行数:99,代码来源:IndexPack.cs

示例5: 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;
                }
            }
开发者ID:spraints,项目名称:GitSharp,代码行数:59,代码来源:WalkFetchConnection.cs


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