Im trying to create a method that allows me to save in a sequential flow i.e. example code:
Private sub BlahWithSave()
'PERFOR ACTIONS
Blah()
Blah2()
'SAVE CHANGES TO DB
General.SaveState()
'CARRY ON PERFORMING ACTIONS AFTER SAVE CARRIED OUT
Blah3()
Blah4()
End Sub
Currently Ive been mucking around with ManualResetEvent and AutoResetEvent but havent got it going so I thought i would ask. Here is my last iteration of the SaveState method:
#Region " SAVE CHANGES "
Private Shared ManualWaitEvent As System.Threading.ManualResetEvent
Public Shared Sub SaveState()
ManualWaitEvent = New System.Threading.ManualResetEvent(False)
MyDataContext.BeginSaveChanges(Sub(result As IAsyncResult)
ManualWaitEvent.Set()
Deployment.Current.Dispatcher.BeginInvoke(Sub()
Dim response As DataServiceResponse = MyDataContext.EndSaveChanges(result)
End Sub)
End Sub, MyDataContext)
ManualWaitEvent.WaitOne()
End Sub
#End Region
The problem is that it just stops at the ManualWaitEvent.WaitOne and never gets into the BeginSaveChanges callback. Any ideas on where im going wrong? Or another idea on how I can acomplish this.
Thanks