This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://blog.stephencleary.com/2015/04/a-tour-of-task-part-10-promise-tasks.html | |
public Task<string> GetValueAsync(int key) | |
{ | |
string result; | |
if (cache.TryGetValue(key, out result)) | |
return Task.FromResult(result); | |
return DoGetValueAsync(key); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/a/14933245 | |
class JobProcessor<TInput, TOutput> : IDisposable | |
{ | |
private readonly Func<TInput, TOutput> m_transform; | |
// or a custom type instead of Tuple | |
private readonly | |
BlockingCollection<Tuple<TInput, TaskCompletionSource<TOutput>>> | |
m_queue = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://forums.xamarin.com/discussion/comment/119662/#Comment_119662 | |
public class IconTabbedRenderer : TabbedRenderer | |
{ | |
protected override void DispatchDraw( | |
global::Android.Graphics.Canvas canvas) | |
{ | |
base.DispatchDraw(canvas); | |
SetTabIcons(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://blog.adamkemp.com/2014/10/c-finalizers-and-idisposable.html | |
public class UnmanagedResourceHolder : IDisposable | |
{ | |
private bool _disposed; | |
private OtherDisposableObject _otherDisposable; | |
public UnmanagedResourceHolder() | |
{ | |
AcquireUnmanagedResource(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.knowing.net/index.php/2014/07/10/ | |
interface IFoo | |
{ | |
//Methods defined here, as always, must be implemented | |
void Necessary (); | |
} | |
static class IFoo_Extensions | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Xamarin.Forms; | |
using Xamarin.Forms.Xaml; | |
namespace Test | |
{ | |
public class DataTemplateSelectorExtension : IMarkupExtension | |
{ | |
public Page Page { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// List of interesting NuGet PCLs | |
Conditions | |
ExifLib | |
SharpSerializer | |
PCLStorage | |
BouncyCastlePCL (encryption) | |
Sockets | |
MathNet.Numerics | |
Zeroconf (Bonjour) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://blog.stephencleary.com/2015/04/a-tour-of-task-part-10-promise-tasks.html | |
interface IPlugin | |
{ | |
// Permit each plugin to initialize asynchronously. | |
Task InitializeAsync(); | |
} | |
class MyPlugin : IPlugin | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://blog.stephencleary.com/2013/01/async-oop-2-constructors.html | |
public sealed class MyClass | |
{ | |
private MyData asyncData; | |
private MyClass() { ... } | |
private async Task<MyClass> InitializeAsync() | |
{ | |
asyncData = await GetDataAsync(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://msdn.microsoft.com/en-us/library/hh228604(v=vs.110).aspx | |
using System; | |
using System.Collections.Concurrent; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Net.Http; | |
using System.Text; | |
using System.Threading.Tasks; |
OlderNewer