简体   繁体   English

Template10显示繁忙的任务延迟

[英]Template10 Show Busy Task Delay

I am loocking for show a Busy page meanwhile some methods are working on my Project with Template10. 我希望显示繁忙页面,同时使用Template10在我的项目中使用某些方法。

Currently I have implemented: 目前,我已经实现了:

await Task.Run(() => Methods());

I think this isn't correct because using this way some methods (with loops) are broken and the bindablebase too. 我认为这是不正确的,因为使用这种方式会破坏某些方法(带有循环),并且bindablebase也是如此。

My code: 我的代码:

private static void SetBusy_NewProject(bool busy, string text = null)
{
    WindowWrapper.Current().Dispatcher.Dispatch(async () =>
    {
        var modal = Window.Current.Content as ModalDialog;
        var view = modal.ModalContent as Busy;
        if (view == null)
            modal.ModalContent = view = new Busy();
        modal.IsModal = view.IsBusy = busy;
        view.BusyText = text;

        await Task.Run(() => Methods.Groups.Body());                
        await Task.Run(() => Methods.Groups.Steel());
        await Task.Run(() => Methods.Groups.CU());
        await Task.Run(() => Methods.Groups.FP());

        await Task.CompletedTask;
        SetBusy_NewProject(false);

    });
}

Can you say me the correct way to show a Busy page meanwhile some methods are working. 您能说出某些方法正在起作用的同时显示“忙碌”页面的正确方法吗?

Any help is appreciated. 任何帮助表示赞赏。

For use the Template10 Busy page in the Hamburger template, you only have to call the Views.Busy.SetBusy(true, "My Loading text") method before the Tasks and the Views.Busy.SetBusy(false) after the awaited Tasks. 要使用Hamburger模板中的Template10 Busy页面,只需在Tasks之前调用Views.Busy.SetBusy(true, "My Loading text")方法,在等待的Tasks之后Views.Busy.SetBusy(false) No need to copy the Busy class' code. 无需复制忙类的代码。 Eg.: 例如。:

Views.Busy.SetBusy(true, "My Loading text");

await Task.Run(() => Methods.Groups.Body());                
await Task.Run(() => Methods.Groups.Steel());
await Task.Run(() => Methods.Groups.CU());
await Task.Run(() => Methods.Groups.FP());

Views.Busy.SetBusy(false);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM