내가 사용하고 비동기 작업 방법 :비동기 및 대기 동작 메서드. 비동기로 작업하지 않습니다. 이유를 모르십니까?
public async Task<JsonResult> SetMaterialRequisitionNoteStatus(List<Guid> ids, string statusName, Guid statusId)
{
string resp = string.Empty;
resp = await note.GeneratePartLifeNotifications_ORN(repairNote, "Outsourced Repair Note " + statusName);
if (responce.ToLower() != "ok")
{
responce = responce.Replace("Workorder", "Outsource repair note");
sendNotification(responce);
}
Utilities.SaveEntityInstance(note);
......
}
하지만 내 코드는 비동기 적으로 작동하지 않습니다. GeneratePartLifeNotifications_ORN
메서드에서 결과를 얻을 때까지 기다리는 전화 옆의 줄이 대기합니다. 동일한 동기 코드로 작동합니다. 비동기 동작을 원합니다.
note.GeneratePartLifeNotifications_ORN (repairNote, "Outsourced Repair Note"+ statusName) 구현을 보여줄 수 있습니까? ? –
하이 GeneratePartLifeNotifications_ORN 확장자 방법 –
공공 정적 작업 GeneratePartLifeNotifications_ORN() {반환 작업 .Factory.StartNew (() => { 복귀 notifications.Count == 0 인 "OK": string.Join ("," 알림); }); –