任务与异步vs后台工作者 [英] Task vs async vs backroundworker

查看:63
本文介绍了任务与异步vs后台工作者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,

我实际上面对要在我的应用程序中实现的不同优化路径。为此,我当然会遇到多线程(因为它不会加速进程,只是不会冻结主Ui)。然后为此我必须考虑不同的东西
喜欢。

I am actually facing to different optimization path to be implemented in my application. For that i come to of course multithreading (whuich will not speed up a process bu simply not freeze the main Ui). Then for that I have to consider different things like.

- 我需要在完成一个thred时通知,以便仅在该条件下处理另一个步骤

- i need to be informed when a thred is complete in order to process an other step only in that condition

- 如果需要,我需要能够取消一些任务

- I need to be able to cancel some task if needed

- 我需要向主要用户发送一些反馈

- I need to send some feedback to main ui main needed

然后我通过使用TASK,await关键字,后台工作者来混淆。

Then I come to confusion by using TASK, await keyword, background worker.

何时使用一个而不是另一个?

When to use one instead of an other ?

regarsd

推荐答案

关于这个主题非常非常需要学习,你的问题非常模糊。这些论坛旨在获取特定问题的答案。

There is very, very much on this subject to learn and your question is very vague. These forums are designed for getting answers to specific questions.

其他操作系统通常对同一事物使用不同的术语。一些程序员可能会坚持"线程"。或"任务"有具体的定义,但一般来说他们没有;请参阅
线程(计算) - 维基百科。对于.Net"任务"

任务类
具有完全特定的定义。在内部,.Net任务类使用Windows API线程。另外,

BackgroundWorker Class
在内部使用线程; BackgroundWorker类没有做任何使用线程无法做到的事情,而BackgroundWorker类只是为了让它更容易在GUI程序中执行线程。当我们使用BackgroundWorker时,我们想要获得
的GUI部分。

Other operating systems often use different terminology for the same thing. Some programmers might insist that "thread" or "task" have specific definitions but generally speaking they do not; see Thread (computing) - Wikipedia. For .Net "task" for the Task Class has a totally specific definition. Internally, the .Net Task Class uses Windows API threads. Also, the BackgroundWorker Class uses threads internally; there is nothing that the BackgroundWorker class does that you can't do using threads, the BackgroundWorker class is just designed to make it easier to do threads in GUI programs. It is the GUI part that we want to get when we use a BackgroundWorker.

异步和等待可能非常混乱。一个启示是它们不是多线程的;当线程(多线程)由其他东西创建时,它们通常是必需的。通常其他的东西是另一个程序,例如Windows的

Async and await can be very confusing. One revelation is that they are not multithreading; they are often necessary when threads (multithreading) are created by something else. Quite often the something else is another program, such as Windows.

这整个主题很庞大,可能会让人很困惑,因为我说,找到教程和/或书籍主题。

This entire subject is vast and can be very confusing so as I said, find tutorials and/or books on the subject.


这篇关于任务与异步vs后台工作者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆