只是让我知道下面的代码是异步执行的吗? [英] Just let me know is the following code executed as asynchronously ?

查看:103
本文介绍了只是让我知道下面的代码是异步执行的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的专家,

请告诉我以下代码异步执行?

我的代码如下所示

Dear Experts,
Just let me know is the following code executed as asynchronously ?
My Code is shown below

public class CompanyController : Controller
   {
public delegate void CompanyAuditRecordKeeper(CompanyModel company, string operationType);
    public ActionResult Create(CompanyModel oCompany)
        {
            //some code


            //I Used below code for asynchoronus call AddCompanyAuditRecords
           //some code
            CompanyAuditRecordKeeper auditkeeper = new CompanyAuditRecordKeeper(AddCompanyAuditRecords);
            auditkeeper.BeginInvoke(oCompany, "I", null, null);

            return Json("", JsonRequestBehavior.AllowGet);
        }
         public void AddCompanyAuditRecords(CompanyModel company, string operationType)
        {
         //  some code goes here

        }
  }





我的问题是' AddCompanyAuditRecords '函数是异步执行的吗?



虽然我从MSDN上读到它会异步执行。来自以下链接

https://msdn.microsoft.com/en-us/library/2e08f6yc(v=vs.110).aspx



我的混乱是因为专家而产生的告诉我它不会异步执行请告诉我?



我尝试过:



我的问题是' AddCompanyAuditRecords '函数是否会异步执行?



My Question is Will the 'AddCompanyAuditRecords' function be executed asynchronously?

Although I read it from MSDN that it will be executed asynchronously.From the following link
https://msdn.microsoft.com/en-us/library/2e08f6yc(v=vs.110).aspx

My confusion arises because an expert said me that it won't executed asynchronously please let me know?

What I have tried:

My Question is Will the 'AddCompanyAuditRecords' function be executed asynchronously?

推荐答案

简短的回答是也许。

官方文件说:

The short answer is "maybe".
The official documentation says:
Executes the specified delegate asynchronously with the specified arguments

这很清楚!

但是......接着说:

which is pretty clear!
But... It goes on to say:

on the thread that the control's underlying handle was created on.

这意味着它确实异步执行, 但仅当它执行的代码不是UI线程时才会执行。

所以:也许。

取决于该代码在更广泛的背景下的确切处理方式。

Which means that it does get executed asynchronously, but only if the code it is executed on is not the UI thread.
So: "maybe".
Depends on exactly how that code is working on a wider context.


这篇关于只是让我知道下面的代码是异步执行的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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