Select to view content in your preferred language

using GetItemsSync and GetGroupAsync in same class

854
2
Jump to solution
11-22-2013 06:01 AM
HumzaAkhtar
Deactivated User
Hi,

I am implementing a function which will take username and ID of a person and then list the maps in the root folder and maps in the groups shared by that person in a separate UI. I am putting the results from both GetGroupAsync and GetItemsSync in an array. The idea is to call the new list box class constructor with the array as an argument after both async methods have finished.

Now my problem is that where can I call the constructor of new class. There are three possibilities with three issues

1. put the
nextUI = new Listboxconstructor(array);
in the GetItemsAsync method. The problem is that I dont get the items from the GetGroupsAsync as that method is running in separate thread.

2. put the
nextUI = new Listboxconstructor(array);
in the GetGroupsAsync method. The problem is that I dont get the items from the GetItemsAsync as that method is running in separate thread.

3. put the 
nextUI = new Listboxconstructor(array);
in the main thread. The problem is that I dont get the items from from any method as both methods are running in separate threads.


Any workaround for this issue will be appreciated.
Thanks
0 Kudos
1 Solution

Accepted Solutions
ThadTilton
Esri Contributor
If you are developing on .NET 4.5, I'd recommend using the task-based asynchronous pattern described here:
http://msdn.microsoft.com/en-us/library/vstudio/hh156513.aspx

Otherwise, you can leverage delegates and BeginInvoke to implement a solution that works across multiple threads. See the example here:
http://www.codeproject.com/Articles/100184/How-to-Manage-Multiple-Asynchronous-Calls-by-using


hope that helps! Thad

View solution in original post

0 Kudos
2 Replies
ThadTilton
Esri Contributor
If you are developing on .NET 4.5, I'd recommend using the task-based asynchronous pattern described here:
http://msdn.microsoft.com/en-us/library/vstudio/hh156513.aspx

Otherwise, you can leverage delegates and BeginInvoke to implement a solution that works across multiple threads. See the example here:
http://www.codeproject.com/Articles/100184/How-to-Manage-Multiple-Asynchronous-Calls-by-using


hope that helps! Thad
0 Kudos
HumzaAkhtar
Deactivated User
Dear Thad,
Thanks for the reply. I will use BeginInvoke and EndInvoke
0 Kudos