LibGit2Sharp无响应

时间:2016-11-16 18:39:10

标签: c# git libgit2sharp

我一直在四处寻找,我正在寻找一种方法让我的git文件拉动,但我的发射器没有松散的响应能力。我已经完成了异步阅读,我不确定它是否可能。 现在我有

private void Install() {
       Repository.Clone("Myrepourl", "Localinstall");
}

这是一个相当大的信息拉动,所以我希望给它们更新,因为它从我从总共4个回购拉出来的Rep。 IE

private void Install() {
       Repository.Clone("url", "local");
       installstatus.Text = "Pulling next repo";
       Repository.Clone("url", "local");
}

这可以异步运行还是只能同步工作?

1 个答案:

答案 0 :(得分:1)

使用Clone事件在Task中运行TransferProgress是我的理由。

基于任务的控制台示例:

class MainClass
{
    public static void Main(string[] args)
    {
        Task.Run(() =>
        {
            Repository.Clone("https://github.com/sushihangover/SVGKit.Binding", Path.Combine(Path.GetTempPath(), "foobar"),
                new CloneOptions { OnTransferProgress = MainClass.TransferProgress });
        }).Wait();
    }

    public static bool TransferProgress(TransferProgress progress)
    {
        Console.WriteLine($"Objects: {progress.ReceivedObjects} of {progress.TotalObjects}, Bytes: {progress.ReceivedBytes}");
        return true;
    }
}
相关问题