wait until i cook it可以直接加it吗

最新精华博文推荐
【推荐博文】
【专家博文】
【专家博文】
【推荐博文】
【专家博文】
人气最旺专家
领域:数据库
介绍:2008从事ORACLE DBA工作并且开通ITPUB博客 获得过9I OCP 10G OCP 10G OCM,...
领域:数据库
介绍:目前任职有赞科技DBA,负责数据库架构设计和运维工作,擅长数据库系统性能...
<div class="focus_con2" id='ADV_1第九届中国数据库技术大会
博客最新公告
20:53:33 | 阅读 | 评论
1,使用mysqldump --tab可以对数据库产生文本文件格式的备份[root@mygirl ~]# /usr/local/mysql/bin/mysqldump --tab=/root test -u root -pEnter password: mysqldump: Go...
17:35:43 | 阅读 | 评论
本文基于5.7.17源码本文只考虑row 格式binlog主要考虑DML语句,DDL语句比较简单不做考虑其实每次show slave status命令的时候后台会调用函数show_slave_status_send_data进...
13:53:42 | 阅读 | 评论
如何让oracle DB、监听和oem开机启动(dbstart)
让oracle DB、监听和oem开机启动(dbstart)Oracle提供了伴随操作系统自动重启的功能,在Windows中,可以修改“我的电脑--&管...
10:03:39 | 阅读 | 评论
可以还原使用旧版本RMAN所创建的备份,最旧版本为9.2.0.8。在创建备份的数据库版本与还原备份的数据库版本之间必须有支持的升级路径存在。比如,源数据库的版本为11gr2并且...
20:29:04 | 阅读 | 评论
Oracle使用SQL*Plus生成html文件
SQL*Plus生成html文件 12:12 by 潇湘隐者, 556 阅读, 9 评论, 收藏, 编辑spool salgrade.htmlspool offexit 如何使用SQ...
09:38:12 | 阅读 | 评论
客户有这样一个需求:有一个大表A,有主键,经常需要往这个表中批量插入大量数据,但插入的数据可能自身重复或者跟表A重复。下面测试几种插入的方法:DB:ORACLE 11.2.0.4新...
14:38:26 | 阅读 | 评论
一:最初alter的复杂过程。MySQL 5.5之前除了MySQL 5.1的 innodb plugin之外,对于索引的添加或删除这类DDL操作,MySQL数据库的操作过程为如下:(1)首先创建新的临时表,...
16:37:37 | 阅读 | 评论
【MySQL】参数wait_timeout和interactive_timeout的作用和区别是什么?
真题1、参数wait_timeout和interactive_timeout的作用和区别是什么?答案:interactive_timeout...
17:04:25 | 阅读 | 评论
【MySQL】通过show status 优化数据库性能
官方文档:https://dev.mysql.com/doc/refman/5.7/en/show-status.html
点击(此处)折叠或打开 mysql& ? show status Name: &#039;...
11:30:58 | 阅读 | 评论
如何将一个数字转换为字符串并且按照指定格式显示?--TO_CHAR1.1.1.1
如何将一个数字转换为字符串并且按照指定格式显示?在应用中,可能需要将0.70%,或需要显示...
09:51:54 | 阅读 | 评论
学习Django的时候,总是觉得这部分内容和实际的应用有一定的差别或者距离。一方面Django自带的ORM对于底层数据库来说是一种适配性很强的组件,可以不强依赖于某一种数...
09:42:35 | 阅读 | 评论
作者介绍杨建荣,DBAplus社群联合发起人,现任竞技世界资深数据库工程师,Oracle ACE、YEP成员,超8年数据库开发和运维经验,擅长数据管理、数据迁移、性能优化,目前专注...
09:38:58 | 阅读 | 评论
我们继续昨天的内容使用Oracle中的emp,dept来学习Django ORM,今天做一些总结和扩展,希望你能有所收获。先来说下两张表emp,dept。emp表的数据如下:dept表的数据如下:然...
09:34:15 | 阅读 | 评论
中间件MyCAT自己之前也简单测试过,总结过。最近做分布式测试,我大体分了三个阶段:一.环境部署,MHA和MyCAT的融合,读写分离二.sharding策略和分库分表的压力测试三.结合...
09:31:55 | 阅读 | 评论
MySQL中的存储引擎是插件式的,当然主流默认的是InnoDB,而且InnoDB存储引擎会随着MySQL官方的搭理投入会越来越火。有了MGR,还有InnoDB Cluster,其实听起来很炫彩,本质上I...
一周热评博文
一周热点博文Wait-For-It
Skills匹配方式英雄全部英雄米波(400)影魔(79)大地之灵(70)伐木机(51)炼金术士(42)风暴之灵(41)修补匠(30)祈求者(26)莉娜(25)圣堂刺客(23)敌法师(21)小小(21)斯拉达(19)哈斯卡(18)赏金猎人(17)风行者(16)痛苦女王(16)斯拉克(16)斧王(14)变体精灵(14)宙斯(12)拉席克(12)熊战士(12)昆卡(11)嗜血狂魔(10)米拉娜(10)帕吉(10)军团指挥官(10)卓尔游侠(9)力丸(9)虚空假面(9)撼地者(8)幻影刺客(8)殁境神蚀者(8)冥界亚龙(7)沙王(6)斯温(6)狙击手(6)兽王(6)露娜(6)噬魂鬼(6)暗夜魔王(6)编织者(6)马格纳斯(6)钢背兽(6)主宰(5)死亡先知(5)戴泽(5)德鲁伊(5)干扰者(5)巨牙海民(5)工程师(5)恐怖利刃(5)寒冬飞龙(5)瘟疫法师(4)冥魂大帝(4)先知(4)育母蜘蛛(4)酒仙(4)娜迦海妖(4)天穹守望者(4)幻影长矛手(3)莱恩(3)潮汐猎人(3)谜团(3)全能骑士(3)杰奇洛(3)蝙蝠骑士(3)远古冰魄(3)矮人直升机(3)暗影恶魔(3)亚巴顿(3)灰烬之灵(3)帕克(2)剃刀(2)复仇之魂(2)龙骑士(2)末日使者(2)裂魂人(2)狼人(2)食人魔魔法师(2)巨魔战将(2)神谕者(2)祸乱之源(1)巫医(1)巫妖(1)术士(1)黑暗贤者(1)克林克兹(1)魅惑魔女(1)陈(1)幽鬼(1)沉默术士(1)混沌骑士(1)拉比克(1)司夜刺客(1)光之守卫(1)艾欧(1)美杜莎(1)半人马战行者(1)上古巨神(1)凤凰(1)物品统计
冀ICP备号-6|
您尚未认证steam账号,
您尚未认证steam账号,I have the following async long running method inside my asp.net mvc-5 web application :-
public async Task&ScanResult& ScanAsync(string FQDN)
// sample of the operation i am doing
var c = await context.SingleOrDefaultAsync(a=&a.id == 1);
var list = await context.Employees.ToListAsync();
await context.SaveChangesAsync();
and i am using Hangfire tool which support running background jobs to call this async method on timely basis, but un-fortuntly the hangefire tool does not support calling async methods directly . so to overcome this problem i created a sync version of the above method , as follow:-
public void Scan()
ScanAsync("test").Wait();
then from the HangFire scheduler i am calling the sync method as follow:-
RecurringJob.AddOrUpdate(() =& ss.Scan(), Cron.Minutely);
so i know that using .Wait() will mainly occupy the iis thread during the method execution ,, but as i mentioned i need to do it in this way as i can not directly call an async TASK inside the hangefire scheduler .
so what will happen when i use .Wait() to call the async method ?, will the whole method's operations be done in a sync way ? for example as shown above i have three async operations inside the ScanAsync() ;SingleOrDefualtAsync,ToListAsync & SaveChangesAsync, so
will they be executed in sync way because i am calling the ScanAsync method using .wait() ?
so what will happen when i use .Wait() to call the async method ?,
will the whole method's operations be done in a sync way ? for example
as shown above i have three async operations inside the ScanAsync()
SingleOrDefualtAsync,ToListAsync & SaveChangesAsync, so will they be
executed in sync way because i am calling the ScanAsync method using
The methods querying the database will still be executed asynchronously, but the fact that you're calling Wait means that even though you're releasing the thread, it wont return to the ASP.NET ThreadPool as you're halting it.
This is also a potential for deadlocks, as ASP.NET has a custom synchronization context which makes sure the context of the request is availiable when in a continuation of an async call.
I would recommend that instead, you'd use the synchronous API provided by entity-framework, as you won't actually be enjoying the scalability one can get from asynchronous calls.
In the comments, you asked:
As i am currently doing with hangefire eliminate the async effect ? if yes then will it be better to use sync methods instead ? or using sync or async with hangeffire will be exactly the same
First, you have to understand what the benefits of async are. You don't do it because it's cool, you do it because it serves a purpose. What is that purpose? Being able to scale under load. How does it do that? When you await an async method, control is yielded back to the caller. For example, you have an incoming request, you query you database. You can either sit there and wait for the query to finish, or you can re-use that thread to serve more incomong requests. That's the true power.
If you don't actually plan on receiving a decent amount of requests (such that you'll starve the thread-pool), you won't actually see any benefit from async. Currently, the way you've implemented it, you won't see any of those benefits because you're blocking the async calls. All you'll see, possibly, are deadlocks.
本文地址: &
public async任务& ScanResult& ScanAsync(string FQDN) { //我正在做的操作的样本 var c = await context.SingleOrDefaultAsync(a =& a.id == 1);
var list = await context.Employees.ToListAsync(); 等待context.SaveChangesAsync();
// etc .. }
我正在使用Hangfire工具支持运行后台作业来及时调用这个异步方法,但是,hangefire工具不支持直接调用异步方法。所以要克服这个问题,我创建了一个同步版本的上述方法,如下所示: -
public void Scan() { ScanAsync(“test”)。Wait(); }
然后从HangFire调度程序调用同步方法如下: -
RecurringJob.AddOrUpdate(()=& ss.Scan(),Cron.Minutely);
所以我知道使用 .Wait()将主要在方法执行期间占用iis线程,但正如我所提到的,我需要这样做,因为我不能直接在hangefire调度程序中调用异步任务。
所以当我使用 .Wait()调用异步方法时会发生什么,整个方法的操作是否以同步的方式完成?例如如上所示,我在 ScanAsync();
SingleOrDefualtAsync ,中有三个异步操作ToListAsync &
SaveChangesAsync ,所以它们将以同步方式执行,因为我使用.wait()调用ScanAsync方法?
所以当我使用.Wait()来调用异步方法会发生什么,将整个方法的操作完成同步办法 ?例如如上所示,我在ScanAsync()中有三个异步操作; SingleOrDefualtAsync,ToListAsync& SaveChangesAsync,所以它们将以同步方式执行,因为我使用 .wait()调用ScanAsync方法?
查询数据库的方法仍然是异步执行的,但是您调用等待的事实意味着即使您发布了该线程,它也不会返回到ASP.NET ThreadPool当您停止它。
这也是一个潜在的死锁,因为ASP.NET有一个自定义的同步上下文,确保当继续异步调用时,请求的上下文是可用的。
我建议您使用实体框架提供的同步API,因为您实际上不会享受从异步调用中获得的可扩展性
在评论中,您问: >
由于我目前正在使用hangefire来消除异步效应?如果是,那么会更好地使用同步方法吗?或使用与hangeffire的同步或异步将是完全一样的
首先,你必须明白异步的好处。你不这么做,因为它很酷,你这样做是因为它的目的。这是什么目的?能够在负载下缩放。怎么做呢当您等待一个异步方法时,控制将返回给调用者。例如,您有一个传入请求,您可以查询数据库。您可以坐在那里等待查询完成,也可以重新使用该线程来提供更多不相同的请求。这是真正的力量。
如果你实际上没有计划收到一个体面的请求(这样你会饿死线程池),你赢了'实际上看到异步的任何好处。目前,您已实施该方案,因为您阻止异步通话,所以您将看不到任何好处。所有你会看到,可能是死锁。
本文地址: &
扫一扫关注官方微信您要找的是不是:
等着瞧吧;等一下
等着瞧吧;等一下
wait on it
the beginning has always been like this, but when some people go faster, some slower, which is the speed with the network, or a relationship, wait on it, or try several times. Unless it is a network problem, and will get in at all.
基于1个网页-
Create a private final Object and call wait() on it.
创建一个私人最终对象和呼叫等待()就可以了。
Green food, food of organic food, natural food, clean food, free from contamination also makes wait on international, it is 70 time first by German put forward first.
绿色食品,国际上也叫有机食品、自然食品、清洁食品、 无污染食品等,它是70年代初由德国人首次提出的。
We all have had that moment when we receive a present only to put it in the storage room later. Other times, we can't wait to try it on.
我想大家都有过这种体验,每次收到礼物都不会立马打开,而是默默地把它放到房间,等过了一段时间才迫不及待地要打开来看。
"So if you are going to end it, you end it on your terms and your time or you wait until there is a crisis."
VOA: standard.
They were speeding the mail so that it didn't have to wait to sort it before it went on the train-- it was sorted while it was moving on the train.
发信速度很快,以致于在上火车之前不再需要,等着分类整理-,可以边坐火车边整理。
Food's more important than family, right. What about how fast the sort of lack of control and now I can kind of binge on it or eat it, I don't even have to wait until the family sits down to eat.
食物比家庭更重要,理解成自身对食物的迅速失控怎么样,暗示自己,现在我可以大快朵颐一番,我甚至都不用等家人全坐下就开始猛吃
"I can't wait to get on it, " said Barbara Lippincott, who's taken 160 cruises on Royal Caribbean and was among a number of the company's devotees at a Manhattan event unveiling the ship's features.
There are hundreds of studies that show businesses who focus on growth during bad economic times do better than competitors who lose their focus and attempt to wait it out on the sidelines.
Obama said at a news conference on Tuesday that the United States would wait until it has more details on evidence of chemical weapons use in Syria before making any decision on whether to alter strategy.
$firstVoiceSent
- 来自原声例句
请问您想要如何调整此模块?
感谢您的反馈,我们会尽快进行适当修改!
请问您想要如何调整此模块?
感谢您的反馈,我们会尽快进行适当修改!

我要回帖

更多关于 it can wait 的文章

 

随机推荐