- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试同步运行异步任务,并且想知道 .RunSynchronously()
之间有什么区别和GetAwaiter().GetResult()
是。
我见过很多 .Wait()
之间的比较以及这两种方法,但没有将其中一种与另一种进行比较。
最佳答案
RunSyncronously
表示使用当前调度程序在当前线程上运行委托(delegate)。但是,这适用:
另一方面,If the target scheduler does not support running this task on the calling thread, the task will be scheduled for execution on the scheduler, and the calling thread will block until the task has completed execution
Wait
或 GetAwaiter().GetResult()
根本不安排 Task
,它只是阻止调用线程直到任务完成。如果从单线程同步上下文调用此操作可能会死锁。
关于c# - .RunSynchronously() 和 GetAwaiter().GetResult() 之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48932626/
这个问题在这里已经有了答案: Calling async methods from non-async code (4 个答案) 关闭 3 年前。 我有一个需要同步调用的异步任务(是的,不幸的是,这
在设置中打开位置后,task.getResult() 返回 null。如果再试一次,一切都会好的。问题是什么 ?这是代码 mFusedLocationProviderClient = Location
从我读过的内容来看,有一种方法可以使用嵌套类来解决具有 22 个以上字段的表的问题。它看起来像这样(有一个简单的表格): case class UserRow(id:Int, address1:Add
我已经实现了一个 javascript 类,并且使用 this.loadResults('cpu').bind(this) 来加载特定结果,该结果可以根据字符串进行区分 - 例如 cpu 或 othe
在以下示例中使用 Doctrine 和 Symfony2 使用 getResult() 方法返回的数组的格式是什么: $query = $this->_em->createQuery('SELECT
在我的 Symfony2 Controller 中,我有两个查询: 就像这个例子一样: $object = $this->getDoctrine()->getManager()
我在 sql server 数据库中有一个存储过程,它包含一个 select 语句,因此在调用存储过程时它应该作为结果集返回: Create Procedure SqlTxFunctionTestin
我有一些非常简单的代码来检查是否有更新: com.google.android.play.core.tasks.Task appUpdateInfo = AppUpdateManagerFactory
我进行了搜索,看看是否能找到我的答案,但这完全是我没有使用正确的术语,所以如果我错过了,请随意拍拍我的后脑勺,并将我链接到正确的页面它:) 我正在做的是在表中搜索特定项目,在本例中是 MAC 地址。如
我有一个名为“Video”的实体,附加到它的是由 ManyToOne 和 ManyToMany 关联的其他实体。 我的问题是,正在执行的查询量与常规流量不相符。例如,我在首页上执行的查询数量不定,大约
我正在努力将我的函数从 MySQL 转移到 MySQLi 标准。 这是我以前的 getresult 函数 function getResult($sql) { $resul
我在处理 JavaFX 时遇到问题 Dialog类(class)。我创建了一个带有自定义类型参数的对话框,比如说 String为简单起见。现在,每当我尝试获取对话框的结果时,我都会得到 ClassCa
是否可以更改 Doctrine2 中 getResult() 的数组键值? 例子: $qb->select('t.id, t.name')->from('Table', 't'); 当我打印这个时,我
这是使用灵活 SQL 时的常见模式 implicit private val mapper = GetResult[MyClass]{r => MyClass(r.<<, r.<<, r.<<,
/** * Search result information between two dates * *@Route("/search/{startDate}/{endDate}/{
我想获取 getServerResult() 方法的结果,但返回“null”。但是,httpURLConnectionPost()方法中的Logcat正常,返回“成功”。请回答我!在这种情况下,为什么
使用 slick 并遵循示例,我创建了一个隐式 val 来转换我的结果,如下所示: implicit val getLocationResult = GetResult(r => LkpLocatio
private void storeFirestore(@NonNull Task task, String user_name) { Uri download_uri; if(tas
我正在尝试从 android studio 中的 Intent 中获取结果。 在我的 main 中,我开始一个 Activity 并使用 startActivityForResult(intent,
我使用 doctrine 2 开发 symfony 2 应用程序。我的代码是: $userSites = $this->getDoctrine()->getManager()
我是一名优秀的程序员,十分优秀!