Last active
June 17, 2016 16:10
-
-
Save haruair/40cac8effe6f9c0a7152ad1700540df1 to your computer and use it in GitHub Desktop.
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 System.Linq; | |
| using System.Threading.Tasks; | |
| using System.Collections.Generic; | |
| namespace Playground | |
| { | |
| class MainClass | |
| { | |
| public static void Main (string[] args) | |
| { | |
| Console.WriteLine ("Hello World!"); | |
| var tester = new Tester (); | |
| foreach(var text in tester.dataList) { | |
| Console.WriteLine (text); | |
| } | |
| } | |
| } | |
| class Tester | |
| { | |
| private IList<string> _list = null; | |
| public IList<string> dataList { | |
| get { | |
| if (_list == null) { | |
| InitAsync ().Wait (); | |
| } | |
| return _list; | |
| } | |
| } | |
| public void Init () | |
| { | |
| _list = Task.Run (async () => await GetListAsync ()).Result; | |
| } | |
| public async Task InitAsync () | |
| { | |
| _list = await GetListAsync (); | |
| } | |
| public async Task<IList<string>> GetListAsync() | |
| { | |
| await Task.Delay (1000); | |
| return new List<string> { "Hello", "World" }; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment