├── .gitignore ├── Core ├── App.cs ├── BackgroundPage.xaml ├── BackgroundPage.xaml.cs ├── DownloadPage.xaml ├── DownloadPage.xaml.cs ├── FormsBackgrounding.csproj ├── LongRunningPage.xaml ├── LongRunningPage.xaml.cs ├── Messages │ ├── CancelledMessage.cs │ ├── DownloadFinishedMessage.cs │ ├── DownloadMessage.cs │ ├── DownloadProgressMessage.cs │ ├── StartLongRunningTaskMessage.cs │ ├── StopLongRunningTaskMessage.cs │ └── TickedMessage.cs ├── Properties │ └── AssemblyInfo.cs ├── TaskCounter.cs └── packages.config ├── Droid ├── Assets │ └── AboutAssets.txt ├── FormsBackgrounding.Droid.csproj ├── ImageHelper.cs ├── MainActivity.cs ├── Properties │ ├── AndroidManifest.xml │ └── AssemblyInfo.cs ├── Resources │ ├── AboutResources.txt │ ├── Resource.designer.cs │ ├── drawable-hdpi │ │ └── icon.png │ ├── drawable-xhdpi │ │ └── icon.png │ ├── drawable-xxhdpi │ │ └── icon.png │ └── drawable │ │ └── icon.png ├── Services │ ├── DownloaderService.cs │ └── LongRunningTaskService.cs └── packages.config ├── FormsBackgrounding.sln ├── XamarinFormsBackgrounding.zip └── iOS ├── AppDelegate.cs ├── Entitlements.plist ├── FormsBackgrounding.iOS.csproj ├── ITunesArtwork ├── ITunesArtwork@2x ├── Info.plist ├── Main.cs ├── Resources ├── Default-568h@2x.png ├── Default-Portrait.png ├── Default-Portrait@2x.png ├── Default.png ├── Default@2x.png ├── Icon-60@2x.png ├── Icon-60@3x.png ├── Icon-76.png ├── Icon-76@2x.png ├── Icon-Small-40.png ├── Icon-Small-40@2x.png ├── Icon-Small-40@3x.png ├── Icon-Small.png ├── Icon-Small@2x.png ├── Icon-Small@3x.png └── LaunchScreen.storyboard ├── Services ├── CustomSessionDownloadDelegate.cs ├── Downloader.cs └── iOSLongRunningTaskExample.cs └── packages.config /.gitignore: -------------------------------------------------------------------------------- 1 | #Autosave files 2 | *~ 3 | 4 | #build 5 | [Oo]bj/ 6 | [Bb]in/ 7 | packages/ 8 | TestResults/ 9 | 10 | # globs 11 | Makefile.in 12 | *.DS_Store 13 | *.sln.cache 14 | *.suo 15 | *.cache 16 | *.pidb 17 | *.userprefs 18 | *.usertasks 19 | config.log 20 | config.make 21 | config.status 22 | aclocal.m4 23 | install-sh 24 | autom4te.cache/ 25 | *.user 26 | *.tar.gz 27 | tarballs/ 28 | test-results/ 29 | Thumbs.db 30 | 31 | #Mac bundle stuff 32 | *.dmg 33 | *.app 34 | 35 | #resharper 36 | *_Resharper.* 37 | *.Resharper 38 | 39 | #dotCover 40 | *.dotCover 41 | -------------------------------------------------------------------------------- /Core/App.cs: -------------------------------------------------------------------------------- 1 | using Xamarin.Forms; 2 | using System; 3 | 4 | namespace FormsBackgrounding 5 | { 6 | public class App : Application 7 | { 8 | #region Constructor 9 | private readonly BackgroundPage _backgroundPage; 10 | 11 | public App () 12 | { 13 | _backgroundPage = new BackgroundPage (); 14 | 15 | var tabbedPage = new TabbedPage (); 16 | tabbedPage.Children.Add (_backgroundPage); 17 | tabbedPage.Children.Add (new LongRunningPage ()); 18 | tabbedPage.Children.Add (new DownloadPage ()); 19 | 20 | MainPage = tabbedPage; 21 | } 22 | #endregion 23 | 24 | protected override void OnStart () 25 | { 26 | LoadPersistedValues (); 27 | } 28 | 29 | protected override void OnSleep () 30 | { 31 | Application.Current.Properties ["SleepDate"] = DateTime.Now.ToString("O"); 32 | Application.Current.Properties ["FirstName"] = _backgroundPage.FirstName; 33 | } 34 | 35 | protected override void OnResume () 36 | { 37 | LoadPersistedValues (); 38 | } 39 | 40 | private void LoadPersistedValues() 41 | { 42 | if (Application.Current.Properties.ContainsKey("SleepDate")) { 43 | var value = (string)Application.Current.Properties ["SleepDate"]; 44 | DateTime sleepDate; 45 | if (DateTime.TryParse (value, out sleepDate)) { 46 | _backgroundPage.SleepDate = sleepDate; 47 | } 48 | } 49 | 50 | if (Application.Current.Properties.ContainsKey("FirstName")) { 51 | var firstName = (string)Application.Current.Properties ["FirstName"]; 52 | _backgroundPage.FirstName = firstName; 53 | } 54 | } 55 | 56 | } 57 | } -------------------------------------------------------------------------------- /Core/BackgroundPage.xaml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 20 | 21 | 27 | -------------------------------------------------------------------------------- /Core/BackgroundPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xamarin.Forms; 3 | using FormsBackgrounding.Messages; 4 | 5 | namespace FormsBackgrounding 6 | { 7 | public partial class BackgroundPage : ContentPage 8 | { 9 | public BackgroundPage () 10 | { 11 | InitializeComponent (); 12 | } 13 | 14 | public DateTime SleepDate 15 | { 16 | set { 17 | this.SleepDateLabel.Text = value.ToString ("t"); 18 | } 19 | } 20 | 21 | public string FirstName 22 | { 23 | get { 24 | return this.FirstNameEntry.Text; 25 | } 26 | set { 27 | this.FirstNameEntry.Text = value; 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Core/DownloadPage.xaml: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |