hoons 닷넷 정기세미나

24
Hoons 닷닷 닷닷닷닷닷

Upload: -

Post on 06-Aug-2015

1.210 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: Hoons 닷넷 정기세미나

Hoons 닷넷 정기세미나

Page 2: Hoons 닷넷 정기세미나

Windows 8 Sysop

Hoons 닷넷 6 기 Silverlight Sysop

Hoons 닷넷 7 기 Windows 8 Sysop

HugeFlow 근무 Windows 8 13 인의 멘토 그룹 해커톤 , WOWZAPP Windows 8 C# 멘토로 활동 서울 시립대 C# 및 Windows 8 강의 현재 Windows 8 용 멜론앱 개발중

Page 3: Hoons 닷넷 정기세미나

Agenda

C# 의 변천사 C# 5.0 (Caller)

C# 의 비동기 패턴 C# 5.0 비동기 패턴 Question

Page 4: Hoons 닷넷 정기세미나

C# 1.0

Managed Code

Delegate

Page 5: Hoons 닷넷 정기세미나

C# 2.0

Primitive Type

Custom Type

object

Boxing

Unboxing

Generic

Page 6: Hoons 닷넷 정기세미나

C# 3.0

Query Ex-pression

• var query = from p in People select new

{ Name = p.name,

Age = p.age };

Lambda Expression •x => x * x;

Page 7: Hoons 닷넷 정기세미나

C# 4.0

dynamic 타입 지원 인터페이스와 대리자에 Covariance 와 Contravariance 를 지원

Page 8: Hoons 닷넷 정기세미나

C# 의 변천사

C# 1.0Managed Code

C# 2.0Generics

C# 3.0• LINQ

C# 4.0• Dynamic

Programming

C# 5.0• Asynchro-

nous Programming

Page 9: Hoons 닷넷 정기세미나

Caller

CallerFilePath

CallerLineNumber

CallerMemberName

Page 10: Hoons 닷넷 정기세미나

CallerMemberName

Caller occurs within Member name result

Method, property or event 호출한 메서드나 프로퍼티나 이벤트의 이름

Constructor “.ctor” 문자열

Static Constructor “.cctor” 문자열

Destructor “Finalize” 문자열

Page 11: Hoons 닷넷 정기세미나

Demo

Page 12: Hoons 닷넷 정기세미나

비동기 프로그래밍 ?

복잡한 작업이 프로그램의 나머지 부분들과 동시에 실행할 수 있도록 구현하는 기술 .

주로 복잡한 작업이나 오래 걸리는 작업으로 인해 UI 가 동작하지 않고 멈추는 현상이 발생하는 그래픽 UI 가 있는 프로그램에서 사용된다 .

Page 13: Hoons 닷넷 정기세미나

Synchronous vs. asynchronousvar data = DownloadData(...);

ProcessData(data);

var future = DownloadDataAsync(...); future.ContinueWith(data => ProcessData(data));

DownloadDataAsync ProcessData

STOP

ProcessDataDownloadData

Page 14: Hoons 닷넷 정기세미나

C# 에서 제공하는 비동기 패턴

Thread

ThreadPool

Event based pattern

IAsyncResult pattern

Task based asynchronous pattern

Etc….

Page 15: Hoons 닷넷 정기세미나

Thread & ThreadPool

닷넷에서 사용되는 가장 기본적인 Thread 객체

Page 16: Hoons 닷넷 정기세미나

Event based pattern

가장 많이 사용하는 비동기 방식 이벤트를 통해 완료시점을 알 수 있음 구현에 대한 규칙이 딱히 공식적으로 정해지지 않음

RunWork

Dowork

Completed

Page 17: Hoons 닷넷 정기세미나

IAsyncResult pattern

EndIn-voke

AsyncCallbackBeginInvoke

Page 18: Hoons 닷넷 정기세미나

Task based asynchronous pattern

반환타입에 따라 Task 또는 Task<TResult> 를 반환 접미사로 Async 사용 , 만약 Async 를 사용 중이면 TaskAsync 추가

Page 19: Hoons 닷넷 정기세미나

async / await

public async void GetAsync()

{

await HttpClient.DownloadAsync(…);

}

Page 20: Hoons 닷넷 정기세미나

Demo

Page 21: Hoons 닷넷 정기세미나

Asynchronous methods automatically transform normal code into a callback state machine

Page 22: Hoons 닷넷 정기세미나

private class btnDoWork_ClickStateMachine : IAsyncStateMachine{ // Member fields for preserving locals and other necessary state int $state; TaskAwaiter<string> $awaiter; int result; ... // Method that moves to the next state in the state machine public void MoveNext() { // Jump table to get back to the right statement upon resumption switch (this.$state) { ... case 2: goto Label2; ... } ... // Expansion of await ...; var tmp1 = ThreadPool.RunAsync(delegate { this.result = Compute(); }); this.$awaiter = tmp1.GetAwaiter(); if (!this.$awaiter.IsCompleted) { this.$state = 2; this.$awaiter.OnCompleted(MoveNext); return; Label2: } this.$awaiter.GetResult(); ... }}

Page 23: Hoons 닷넷 정기세미나

Question

Page 24: Hoons 닷넷 정기세미나

To be continue…