第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

將常規(guī)方法轉(zhuǎn)換為異步方法

將常規(guī)方法轉(zhuǎn)換為異步方法

C#
繁華開滿天機(jī) 2021-05-11 17:44:21
我有一個(gè)API,負(fù)責(zé)在數(shù)據(jù)庫中插入短信詳細(xì)信息。它通過對(duì)存儲(chǔ)庫進(jìn)行同步調(diào)用來實(shí)現(xiàn),我認(rèn)為可以異步實(shí)現(xiàn)該存儲(chǔ)庫,我該如何實(shí)現(xiàn)呢?還是最好的方式來處理這種情況。代碼片段示例受到高度贊賞,因?yàn)槲胰栽诶^續(xù)圍繞.NET進(jìn)行包裝。api:public IHttpActionResult SendSMSNotification([FromBody] SMSNotification smsNotification)    {        if (!ModelState.IsValid)        {            return BadRequest(ModelState);        }                    _service.SendSMS(smsNotification);        return Ok();    }服務(wù):internal void SendSMS(SMSNotification smsNotification)    {        _repository.Notify(_mapperService.GetSMSNotification(smsNotification));    }映射器:public SMSNotification GetSMSNotification(SMSNotification message)    {        return AutoMapper.Mapper.Map<SMSNotification>(message);     }回購:public virtual bool Notify(SMSNotification request)    {        using (var sql = _sqlMapper.CreateCommand('Database', 'Stored proc'))        {            sql.AddParam("@fMessage", request.Message);           //..............           //.............. more params            var retvalParamOutput = sql.AddOutputParam("@fRetVal", System.Data.SqlDbType.Int);            sql.Execute();            return retvalParamOutput.GetSafeValue<int>() == 1;        }    }sql這里是一個(gè)自定義的東西,它具有以下方法:  public static int Execute(this IDataCommand @this);        [AsyncStateMachine(typeof(<ExecuteAsync>d__1))]        public static Task<int> ExecuteAsync(this IDataCommand @this);
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 148 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)