Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implement Event-Based Asynchronous Pattern In A Portable Class

I have a few c# class libraries which I share between applications. I want to create a Windows 8 Style App, but it only supports windows 8 class libraries or portable class libraries. Deciding to go with the later I've ported everything without too much difficulty with the exception of Async operations.

Currently my class libraries are implementing the Event-based Asynchronous pattern.

From this example a portable library doesn't seem to support System.Componenent.AsyncOperation/AsyncOperationManager and System.Collections.Specialized.HybridDictionary.

My two questions are:

1) What is a good collection to use instead of HybridDictionary?

2) How can I get around the lack of AsyncOperation/AsyncOperationManager? Do I need to implement a completely different pattern?

UPDATE: In VS 2012 my Portable class library is targeting ".net framework 4 and higher", "Silverlight 4 and higher", "windows phone 7 and higher", ".net for metro style apps".

like image 609
Oli Avatar asked Jan 26 '26 12:01

Oli


1 Answers

1) How many elements are you using in HybridDictionary? If under 10), just use List<T>. Otherwise, use Dictionary<Key, TValue>.

2) I've got a portable version of AsyncOperation/AsyncOperationManager and BackgroundWorker over on http://pclcontrib.codeplex.com/. There's no binaries yet, but just browse the Portable.ComponentModel.Async project for the source code.

like image 184
David Kean Avatar answered Jan 28 '26 02:01

David Kean