Home > Net >  C # for bosses to explain the asynchronous
C # for bosses to explain the asynchronous

Time:09-18

Dear bosses, or less busy work all right before he goes to bed at night, can you help me and explain the theory of asynchronous, what is the "future is complete," the difference between asynchronous and multi-threaded, why can't the asynchronous interpreted, the main thread execution to the asynchronous for asynchronous code block, open a thread to execute, implement after the return to the main thread, for bosses to explain, and the difference between best example code, I will be an instance a instance to knock again

CodePudding user response:

Then they understand that why in 15 years ago, you see the information back to appear so much sleep and so much information about the thread synchronization

Why do you want to sleep, why do you want to thread synchronization? Because we are not only do one thing, we need to do is, you have finished, do then behind

So in its struggle to distinguish, instance,

Might as well to consider, if you're going to do it with the traditional thread, how are you going to do this action do then? Obviously, either the while (true) sleep run polling check, or from another thread waits for synchronous semaphore release, or asynchronous delegate asynchronous notifications out

We're not considering what open a thread, we consider is then do the follow-up

CodePudding user response:

Many people like to use to cook it, speak to multi-threaded, parallel examples

Well, he cooked rice cooker in the back we said "drop ~ ~" singing, inform him ready, waiting for your further processing,
For a thread does not always perform void, in most cases we are asked him to return to the state, that is you said "when he finished the state of the future"

CodePudding user response:

Multi-threading CPU is have a lot of questions to , but the performance is limited, couldn't get on the frequency, you of the code, such as the 100 title, decompose into 10 portions, each 10 questions, give 10 threads to execute, anyway, now the CPU while high frequency will not come up, core is still a lot of, this calculation is fast,

Asynchronous is CPU speed although couldn't get on, but what are the external interface or too fast, network access, disk, speaking, reading and writing, is slowly, if you need to take from the Internet computing when a data, if it is the same main thread in the execution, that at the time of waiting for the main thread card, such as software to display data on a network, the network card, your software will drag down did not move, but where is your CPU is idle die, then use asynchronous, met slow affair CPU to another thread to work, just finished tell me, I can, the so-called future is complete, when we were waiting for the return to do something else, just won't be the card interface,

CodePudding user response:

refer to the second floor wanghui0380 response:
cooking a lot of people like to use it, speak to multi-threaded, parallel examples

Well, he cooked rice cooker in the back we said "drop ~ ~" singing, inform him ready, waiting for your further processing,
For a thread does not always perform void, in most cases we are asked him to return to the state, that is you said "when he finished the state of the future"

I understand your meaning, but I see another post said, don't put the asynchronous and multi-threaded get together to talk about, if implemented, however, is the main thread program, meet requires asynchronous code, to open a thread to execute, and then the main thread to continue to perform the following code, such as asynchronous code after the thread execution returns a Task The state or the return value, after, can understand it?

CodePudding user response:

reference 1st floor wanghui0380 response:
that oneself understand, why in 15 years ago, you see the information back to appear so much sleep and so much information about the thread synchronization

Why do you want to sleep, why do you want to thread synchronization? Because we are not only do one thing, we need to do is, you have finished, do then behind

So in its struggle to distinguish, instance,

Might as well to consider, if you're going to do it with the traditional thread, how are you going to do this action do then? Obviously, either the while (true) sleep run polling check, or from another thread waits for synchronous semaphore release, or asynchronous delegate asynchronous notifications out

We're not considering what open a thread, we consider is just doing follow-up on

I met the problem of how to read and write files, and colleagues told me, you can create a thread, then execute the reading and writing, make the thread to sleep for a few seconds later, through an authorized whether complete monitoring, speaking, reading and writing, but it's too complicated, logical relationship and disorderly, although this problem I solved using asynchronous (baidu c + v), but not sure this difference, and the specific how to achieve,

CodePudding user response:

reference 1st floor wanghui0380 response:
that oneself understand, why in 15 years ago, you see the information back to appear so much sleep and so much information about the thread synchronization

Why do you want to sleep, why do you want to thread synchronization? Because we are not only do one thing, we need to do is, you have finished, do then behind

So in its struggle to distinguish, instance,

Might as well to consider, if you're going to do it with the traditional thread, how are you going to do this action do then? Obviously, either the while (true) sleep run polling check, or from another thread waits for synchronous semaphore release, or asynchronous delegate asynchronous notifications out

We're not considering what open a thread, we consider is just doing follow-up on

Namely, we must to do to do, to do not to perform, but we also need to ensure that interface will not be stuck,

CodePudding user response:

Create a thread execution, speaking, reading and writing,
The main thread joins the child thread,

Don't need to sleep what of,

===
Conceptually, asynchronous is a broad concept, parallel between multiple processes, is asynchronous; Multi-threaded parallel, also is asynchronous, the main thread and the UI thread, the BeginInvoke call is asynchronous; Await async keyword, is asynchronous; Program to access the database, and database program can also realize asynchronous, etc.,

But regardless of the above a variety of ways, implementation may be different, but the underlying should involve multithreading/multiple processes,
  •  Tags:  
  • C#
  • Related