小编clo*_*ypt的帖子

在等待列表<任务>中的所有任务完成时显示进度

我正在尝试在一行的末尾连续打印点作为一种不确定的进展形式,同时运行一大堆任务,使用以下代码:

start = DateTime.Now;
Console.Write("*Processing variables");
Task entireTask = Task.WhenAll(tasks);
Task progress = new Task(() => { while (!entireTask.IsCompleted) { Console.Write("."); System.Threading.Thread.Sleep(1000); } });
progress.Start();
entireTask.Wait();
timeDiff = DateTime.Now - start;
Console.WriteLine("\n*Operation completed in {0} seconds.", timeDiff.TotalSeconds);
Run Code Online (Sandbox Code Playgroud)

哪里tasksList<Task> tasks = new List<Task>();,
tasks.Add(Task.Run(() => someMethodAsync()));已经发生10000周的时期.
这个代码目前有效,但这是实现这一目标的正确方法,这是最具成本效益的方法吗?

.net c# asynchronous task async-await

11
推荐指数
2
解决办法
4839
查看次数

UWP Windows 10 应用程序中页面/视图的通用基类

在使用 Template10 的 UWP-Windows 10 C#/XAML 应用程序中,我目前正在尝试让我的页面/视图从继承自Windows.UI.Xaml.Controls.Page.
这一直正常工作,但是当我尝试使基类通用并以以下方式在子类和 XAML 中包含类型参数时,它不起作用:

namespace App.Views 
{
    public abstract class InfoListViewBase<M> : Page where M : InfoListViewModelBase
    {

        public InfoListViewBase() { }

    }

    public sealed partial class ModelPage : InfoListViewBase<Model>
    {
        public Model()
        {
            InitializeComponent();
            NavigationCacheMode = NavigationCacheMode.Disabled;
        }
    }
}

<local:InfoListViewBase 
    x:Class="App.Views.ModelPage"
    x:TypeArguments="l:Model"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Behaviors="using:Template10.Behaviors"
    xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
    xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
    xmlns:controls="using:Template10.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="using:App.Views"
    xmlns:l="using:Library"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

</local:InfoListViewBase>
Run Code Online (Sandbox Code Playgroud)

我收到的错误是:

The name "InfoListViewBase`1" does not exist in the namespace "using:App.Views".
Run Code Online (Sandbox Code Playgroud)

每次我将该行添加x:TypeArguments="l:Model"到 XAML时都会出现该错误。
在visual …

c# wpf xaml uwp template10

5
推荐指数
1
解决办法
1176
查看次数

Windows 10通用应用程序SQLite

我目前正在尝试将运行中的Windows 8 JavaScript应用移植到Windows 10 UAP应用。在Windows 8应用程序中,我大量使用了SQLite包装器和库:https : //github.com/doo/SQLite3-WinRT。但是,按照仓库的自述文件中的设置说明将SQLite3-WinRT添加到我的Windows 10 UAP应用程序后,我收到了添加到/ js的SQLite3.js源文件的“ WinJS未定义”错误应用中的目录(在Windows 8应用中正常运行的方式)。我在这里做错什么,还是使该SQLite3-WinRT无法在Win 10 UAP中使用,是否有在JavaScript Windows 10 UAP应用程序中使用SQLite的更好方法?非常感谢!

javascript sqlite windows-runtime winjs win-universal-app

4
推荐指数
1
解决办法
1952
查看次数