如何在Silverlight中等待异步方法

编程入门 行业动态 更新时间:2024-10-24 20:14:45
本文介绍了如何在Silverlight中等待异步方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在wcf服务中创建了两个函数,并在Silverlight中使用异步方法进行调用,在一个方法之后但在第一个方法完成之前,请一个方法执行Silverlight执行第二个方法.我希望第一个方法完全执行,然后第二个方法调用.请帮忙.

I am make two function in wcf service and call in silverlight using asynchronization method call one method after one method but before completion of first method silverlight execute the 2nd method. I want first method completely execute then second method call. Please help its urgent.

private GDOperations.GDDoneOperationsClient _gdDoneOperation; private ImageOperationsClient proxy = null; foreach (var file in _filesCollection) { clsImageTransactionEntity _clsImageEntity = new clsImageTransactionEntity(); _clsImageEntity.ImageByte = GetFileData(file.OpenRead()); _clsImageEntity.ImageExtension = file.Extension; _clsImageEntity.ImageName = file.Name; _clsImageEntity.ImageType = 2; _clsImageEntity.ImagePath = "~/CMSImages/FinalImages/" + lblSelectedBarcode.Content.ToString() + "/" + file.Name; _clsImageEntity.JabongBarcode = lblSelectedBarcode.Content.ToString(); GDOperations.clsImageTransactionEntity _clsImageGDEntity = new GDOperations.clsImageTransactionEntity(); _clsImageGDEntity.ImageExtension = file.Extension; _clsImageGDEntity.ImageName = file.Name; _clsImageGDEntity.ImageType = 2; _clsImageGDEntity.ImagePath = "~/CMSImages/FinalImages/" + lblSelectedBarcode.Content.ToString() + "/" + file.Name; _clsImageGDEntity.JabongBarcode = lblSelectedBarcode.Content.ToString(); _clsImageGDEntity.RoleId = roleID; _clsImageGDEntity.TaskID = taskID; _clsImageGDEntity.UserID = UserId; _clsImageGDEntity.SystemIP = systemIP; _clsGdAllotment.clsImageTransactionEntity.Add(_clsImageGDEntity); //----- first method calling----- proxy.UploadFinalImageCompleted += (s, e) => { if (e.Error == null) { } }; proxy.UploadFinalImageAsync(_clsImageEntity); countfile = countfile + 1; pbUploadFiles.Value = countfile; } _clsGdAllotment.GdID = int.Parse(lblUserID.Content.ToString()); _clsGdAllotment.JabongBarcode = lblSelectedBarcode.Content.ToString(); _clsGdAllotment.TaskID = taskID; //--- after for loop completion calling second method ----- _gdDoneOperation.InsertGDDoneInformationCompleted += _gdDoneOperation_InsertGDDoneInformationCompleted; _gdDoneOperation.InsertGDDoneInformationAsync(_clsGdAllotment);

谢谢&关于Ram Kumar

Thanks & Regards Ram Kumar

推荐答案

在第一个的完成处理程序中调用第二个方法.在调用第二个方法之前,请确保您的第一个异步回调成功返回. /ravi Call your 2nd method in the completion handler of the first. Ensure your first async callback returns successfully before calling the 2nd method. /ravi

更多推荐

如何在Silverlight中等待异步方法

本文发布于:2023-11-12 18:54:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582266.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法   如何在   Silverlight

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!