Skip to content

Instantly share code, notes, and snippets.

@haruair
Last active June 17, 2016 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haruair/40cac8effe6f9c0a7152ad1700540df1 to your computer and use it in GitHub Desktop.
Save haruair/40cac8effe6f9c0a7152ad1700540df1 to your computer and use it in GitHub Desktop.
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