public class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public async Task SaveFile()
{
await Task.Run(()=>
using(FileStream fs = new FileStream("trashfile.bin",
FileMode.CreateNew))
{
BinaryWriter bw = new BinaryWriter(fs);
for(int i = 0; i < 100000000; i++)
bw.Write(i);
}
});
}
public async void btnOK_Click(object sender, EventArgs e)
{
await SaveFile();
MessageBox.Show("Complete.");
}
}
비동기 쓰레드를 너무 쉽게 구현 할 수 있어요...
'Functional World > C#' 카테고리의 다른 글
| boxing 에 대한 생각의 오류.... (0) | 2013.09.30 |
|---|---|
| IEnumerator 사용하기 - 기초 (0) | 2013.08.11 |
| Generic Collections (0) | 2013.07.15 |
| Runtime에 클래스 맴버를 취득 하고자 할 경우…. (0) | 2013.07.04 |
| Func<TResult>() 대리자 (0) | 2013.07.04 |




