Skip to content

Instantly share code, notes, and snippets.

@ericbrunner
ericbrunner / Program.cs
Last active August 29, 2016 05:33
Sample Async Await with ContinueWith
class Program
{
class Program
{
static void Main(string[] args)
{
try
{
Task<int> getNumberTask = GetNumberAsync(12);
@ericbrunner
ericbrunner / Task70PhotoUploadPage.xaml.cs
Last active April 8, 2022 09:04
Media Plugin Usage
using Acr.UserDialogs;
using Plugin.Connectivity;
using Plugin.Media;
using Plugin.Media.Abstractions;
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
using System;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
@ericbrunner
ericbrunner / ConsoleDebugOut.txt
Created March 15, 2017 07:27
Console Debug Output
03-15 08:23:29.476 D/Mono (28311): Assembly Ref addref trucker_rolsped[0x5f40fdb8] -> Plugin.Permissions.Abstractions[0x5e3e0e50]: 2
03-15 08:23:29.496 D/Mono (28311): Assembly Ref addref trucker_rolsped[0x5f40fdb8] -> Plugin.Media[0x5e3db0b0]: 2
03-15 08:23:29.496 D/Mono (28311): Assembly Ref addref Plugin.Media[0x5e3db0b0] -> Plugin.Media.Abstractions[0x5e3d9770]: 3
03-15 08:23:29.506 D/Mono (28311): Unloading image System.Threading.Tasks.dll [0x666f4cd0].
03-15 08:23:29.506 D/Mono (28311): Image addref System.Threading.Tasks[0x66a2a690] -> System.Threading.Tasks.dll[0x60893ae8]: 11
03-15 08:23:29.506 D/Mono (28311): Config attempting to parse: 'System.Threading.Tasks.dll.config'.
03-15 08:23:29.506 D/Mono (28311): Config attempting to parse: '/Users/builder/data/lanes/4009/f3074d2c/source/monodroid/builds/install/mono-armv7/etc/mono/assemblies/System.Threading.Tasks/System.Threading.Tasks.config'.
03-15 08:23:29.506 D/Mono (28311): Assembly Ref addref Plugin.Media.Abstractions[0x5e3
@ericbrunner
ericbrunner / ExceptionStackTraceOnRecurringPickMedia.txt
Created March 15, 2017 07:58
Exception Stack Trace on recurring Pick Media invocation
> Xamarin caused by: android.runtime.JavaProxyThrowable: System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> System.IO.IOException: Sharing violation on path /storage/emulated/0/Android/data/com.rolsped.dev.TruckerApp/files/Pictures/temp/IMAG0053_1.jpg
> at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0026d] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/corlib/System.IO/FileStream.cs:249
> at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize) [0x00000] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/corlib/System.IO/FileStream.cs:96
> at (
@ericbrunner
ericbrunner / Stacktrace.txt
Last active March 16, 2017 15:13
Stacktrace
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00033] in <19f6933526e54401995c26c938fd7007>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <19f6933526e54401995c26c938fd7007>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <19f6933526e54401995c26c938fd7007>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <19f6933526e54401995c26c938fd7007>:0
at System.Net.Http.HttpClientHandler+<SendAsync>c__async0.MoveNext () [0x00507] in <f5b55d773f894fe7896e2b238645e7fc>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <19f6933526e54401995c26c938fd7007>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00027] in
@ericbrunner
ericbrunner / OfflineSyncManager.cs
Created March 22, 2017 15:42
OfflineSyncManager
// To add offline sync support: add the NuGet package Microsoft.Azure.Mobile.Client.SQLiteStore
// to all projects in the solution and uncomment the symbol definition OFFLINE_SYNC_ENABLED
// For Xamarin.iOS, also edit AppDelegate.cs and uncomment the call to SQLitePCL.CurrentPlatform.Init()
// For more information, see: http://go.microsoft.com/fwlink/?LinkId=620342
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectGuid>{3AFA591D-C115-4AC9-9519-F788373ECDE9}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>trucker_rolsped</RootNamespace>
<AssemblyName>trucker_rolsped</AssemblyName>
@ericbrunner
ericbrunner / GpsTrackerService.cs
Created May 29, 2017 21:05
GpsTrackerService
[Service]
public class GpsTrackerService : Service
{
bool _isStarted;
static readonly int TimerWait = 60000; // every 60 seconds
Timer _timer;
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
{
if (!_isStarted)
@ericbrunner
ericbrunner / GpsTrackerService.cs
Created June 4, 2017 05:38
GpsTrackerService
using System;
using System.Collections.Generic;
using Android.App;
using Android.Content;
using Android.OS;
using System.Threading;
using System.Threading.Tasks;
using Plugin.Connectivity;
using trucker_rolsped.Models;
using Android.Media;
@ericbrunner
ericbrunner / GpsTrackerServiceBroadcastReceiver.cs
Created June 4, 2017 05:56
GpsTrackerServiceBroadcastReceiver
using System;
using Android.App;
using Android.Content;
using trucker_rolsped.Helper.HockeyApp;
namespace trucker_rolsped.Droid.GeoLocation
{
[BroadcastReceiver(Enabled = true, Exported = true, Name = GpsConstants.GpsBroadcastReceiver, Label = "RestartServiceWhenStopped")]
[IntentFilter(new[] {GpsConstants.GpsRestart})]
public class GpsTrackerServiceBroadcastReceiver : BroadcastReceiver