Skip to content

Instantly share code, notes, and snippets.

View programmation's full-sized avatar

David Dancy programmation

View GitHub Profile
@programmation
programmation / tabbed_icon_renderer.cs
Created May 4, 2015 04:21
Xamarin Forms Android Tab Bar with Icons
// 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();
@programmation
programmation / tpl_job_processor.cs
Created May 4, 2015 04:17
TPL-based job processor
// 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 =
// 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);
}