嗨,我有一个使用web服务引用的WPF应用程序…
现在我有一个GUI组件来跟踪这个进程…
但是我这里似乎有一些错误,它只发生在一些机器上,不经常…我用MethodNameAsync开始调用,并显示进度条,直到匹配的Completed事件发生。
有时我在一行中调用3个不同的异步方法,但只有其中两个得到他们的完成事件,所以GUI将被锁定,应用程序必须重新启动。
在完全沮丧了几个星期后,我发现了事件AppDomain.CurrentDomain。所以我连接到它并开始记录所有的FirstChanceException .
在引发第二个事件之前抛出System.Net.Sockets.SocketException "An invalid argument was provided ",之后抛出System.Net.Sockets.SocketException。抛出ObjectDisposedException "Cannot access a dispose object.",这两个都是第一次异常。
我猜我的WCF客户端忘记了第三个方法调用当这种情况发生时,但我的加载指示器没有…
所以这是一个已知的错误还是我错过了一些东西?
按要求编辑代码:
mCheckInService = New CheckInServiceClient()
AddHandler mCheckInService.GetPersonActivitiesCompleted, AddressOf CheckInService_GetPersonActivitiesCompleted
AddHandler mCheckInService.GetPersonArticlesCompleted, AddressOf CheckInService_GetPersonArticlesCompleted
AddHandler mCheckInService.GetPersonImageCompleted, AddressOf CheckInService_GetPersonImageCompleted
Dim workItem As WorkItem = Context.WorkDisplayService.AddWorkItem(Me, Resources.Label.DownloadingPersomImage)
mCheckInService.GetPersonImageAsync(Context.Session, person, workItem)
workItem = Context.WorkDisplayService.AddWorkItem(Me, "Hämtar aktiviteter")
mCheckInService.GetPersonActivitiesAsync(Context.Session, Person, workItem)
workItem = Context.WorkDisplayService.AddWorkItem(Me, Resources.Label.DownloadingPersonArticles)
mCheckInService.GetPersonArticlesAsync(Context.Session, person, workItem)
Private Sub CheckInService_GetPersonActivitiesCompleted(ByVal sender As Object, ByVal e As GetPersonActivitiesCompletedEventArgs)
Dim workItem As WorkItem = CType(e.UserState, WorkItem)
If (Context.WorkDisplayService.FinishWorkItem(Me, workItem)) Then
Private Sub CheckInService_GetPersonArticlesCompleted(ByVal sender As Object, ByVal e As GetPersonArticlesCompletedEventArgs)
Logger.Trace("CheckInService_GetPersonArticlesCompleted()")
Dim workItem As WorkItem = CType(e.UserState, WorkItem)
If (Context.WorkDisplayService.FinishWorkItem(Me, workItem)) Then
Private Sub CheckInService_GetPersonImageCompleted(ByVal sender As Object, ByVal e As GetPersonImageCompletedEventArgs)
Logger.Trace("CheckInService_GetPersonImageCompleted()")
Dim workItem As WorkItem = CType(e.UserState, WorkItem)
If (Context.WorkDisplayService.FinishWorkItem(Me, workItem)) Then
它的getpersonactitiesasync永远不会完成..
编辑:通过不使用异步方法,而是使用一个线程逐个调用它们来修复这个临时问题。现在这不是一个优雅的解决方案,我应该能够使用异步方法…
这里的提示是"无法访问已处置的对象"。
回调代码有时会发生的情况是,应该监听回调的代码已经被处理掉了,所以当回调返回时,没有人在监听。