본문 바로가기 메뉴 바로가기

Hyunsoo

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

Hyunsoo

검색하기 폼
  • 프로그래밍 (138)
    • C# (113)
      • Winform (34)
      • DevExpress (58)
      • Program (5)
      • 책 예제 (16)
    • Web (4)
      • JavaScript (3)
      • Spring (0)
      • Tomcat (1)
    • DataBase (15)
      • PosegreSQL (12)
      • SQLITE (0)
      • MYSQL (2)
    • ETC (2)
    • 제품구매 (3)
    • Redmine (1)
    • Python (0)
  • 방명록

C#/책 예제 (16)
C# Task 비동기 호출의 병렬 처리 하기

비동기 호출의 병렬 처리 하기 입니다. 아래의 예제는 병렬 처리 하기 전입니다. using System; using System.IO; using System.Threading; using System.Threading.Tasks; namespace TaskSample { class Program { static void Main(string[] args) { int result3 = Method3(); int result5 = Method5(); Console.WriteLine(result3 + result5); } private static int Method3() { Thread.Sleep(3000); // 3초가 걸리는 작업을 대신해서 sleep 처리 return 3; } private stati..

C#/책 예제 2019. 6. 9. 23:33
C# Task ReadAllText 메서드를 비동기로 처리하기.

ReadAllText 메서드를 비동기로 처리하기 입니다. 별도의 스레드를 이용하거나 델리게이트의 BeginInvoke로 처리하여 비동기를 적용하는 예제입니다.(복잡함) using System; using System.IO; namespace TaskSample { class Program { public delegate string ReadAllTextDelegate(string path); static void Main(string[] args) { string filePath = @"C:\windows\system32\drivers\etc\HOSTS"; ReadAllTextDelegate func = File.ReadAllText; func.BeginInvoke(filePath, actionCompl..

C#/책 예제 2019. 6. 9. 23:23
C# Task await 없이 Task타입을 단독으로 사용하는 예제

await 없이 Task타입을 단독으로 사용하는 예제 입니다. Task 타입은 반환값이 없는 경우 사용되며, Task 타입은 TResult 형식 매개 변수로 지정된 반환값이 있는 경우로 구분됩니다. using System; using System.Threading; using System.Threading.Tasks; namespace TaskSample { class Program { static void Main(string[] args) { ThreadPool.QueueUserWorkItem((obj) => { Console.WriteLine("process workItem"); }, null); Task task1 = new Task(() => { Console.WriteLine("Process ..

C#/책 예제 2019. 6. 9. 23:15
C# Task 비동기 API WInform 예제

using System; using System.IO; using System.Threading.Tasks; using System.Windows.Forms; namespace FileCopy { /// /// 메인폼 클래스 입니다. /// public partial class MainForm : Form { // Constructor (Public) #region MainForm() - 생성자 입니다. /// /// 생성자 입니다. /// public MainForm() { InitializeComponent(); #region 이벤트를 설정합니다. this.sourceButton.Click += sourceButton_Click; this.targetButton.Click += targetButton..

C#/책 예제 2019. 6. 8. 12:53
C# Task 비동기 API 예제

using System; using System.IO; using System.Threading.Tasks; namespace ThreadNTask { class Program { static void Main(string[] args) { if(args.Length < 2) { Console.WriteLine("Usage: AsyncFileIO "); return; } DoCopy(args[0], args[1]); Console.ReadLine(); } static async Task CopyAsync(string fromPath, string toPath) { using(var fromStream = new FileStream(fromPath, FileMode.Open)) { long totalCop..

C#/책 예제 2019. 6. 8. 12:10
C# Task async 한정자와 await 연산자 사용하기.

using System; using System.Threading.Tasks; namespace ThreadNTask { class Program { static void Main(string[] args) { Caller(); Console.ReadLine(); } async static private void MyMethodAsync(int count) { Console.WriteLine("C"); Console.WriteLine("D"); await Task.Run(async() => { for(int i = 1; i < count; i++) { Console.WriteLine($"{i}/{count}."); await Task.Delay(1000); } }); Console.WriteLine("G..

C#/책 예제 2019. 6. 8. 12:01
C# Task Parallel 클래스 사용하기.

using System; using System.Collections.Generic; using System.Threading.Tasks; namespace ThreadNTask { class Program { static void Main(string[] args) { long from = Convert.ToInt64(args[0]); long to = Convert.ToInt64(args[1]); Console.WriteLine("Please press enter to start"); Console.ReadLine(); Console.WriteLine("Started"); DateTime startTime = DateTime.Now; List total = new List(); Parallel.For..

C#/책 예제 2019. 6. 8. 11:54
C# Task Task<TResult> 클래스 사용하기.

using System; using System.Collections.Generic; using System.Threading.Tasks; namespace ThreadNTask { class Program { static void Main(string[] args) { long from = Convert.ToInt64(args[0]); long to = Convert.ToInt64(args[1]); int taskCount = Convert.ToInt32(args[2]); Func FindPrintFunc = (objRange) => { long[] range = (long[])objRange; List found = new List(); for(long i = range[0]; i < range[1]..

C#/책 예제 2019. 6. 8. 11:49
C# Task Task 클래스 사용하기.

using System; using System.IO; using System.Threading; using System.Threading.Tasks; namespace ThreadNTask { class Program { static void Main(string[] args) { string srcFile = args[0]; Action fileCopyAction = (object state) => { string[] paths = (string[])state; File.Copy(paths[0], paths[1]); Console.WriteLine("TaskID: {0}, ThreadID: {1}, {2} was copied to {3}", Task.CurrentId, Thread.CurrentThr..

C#/책 예제 2019. 6. 8. 11:24
C# Thread Monitor.Wait 그리고 Monitor.Pulse 사용하기

using System; using System.Threading; namespace ThreadNTask { class Program { static void Main(string[] args) { Counter counter = new Counter(); Thread increaseThread = new Thread(new ThreadStart(counter.Increase)); Thread decreaseThread = new Thread(new ThreadStart(counter.Decrease)); increaseThread.Start(); decreaseThread.Start(); increaseThread.Join(); decreaseThread.Join(); Console.WriteLine..

C#/책 예제 2019. 6. 8. 10:54
이전 1 2 다음
이전 다음
공지사항
최근에 올라온 글
  • DataTable 에서 SELECT 라⋯
  • Table '.\mysql\proc' is⋯
  • MYSQL many connection er⋯
  • Tomcat 에러 Could not de⋯
최근에 달린 댓글
  • 유용한 글 되게 잘 보고 가여
  • 도움되는 글 매우 잘 배우고⋯
  • 유용한 글 정말 잘 배우고 갑⋯
  • 잘 보고 갑니다~~
Total
71,403
Today
5
Yesterday
151
링크
TAG
  • TextEdit
  • node
  • mariadb
  • DevExpress
  • SQLite
  • DateEdit
  • GridControl
  • ContextMenuStrip
  • CheckedListBoxControl
  • TreeView
  • EditMask
  • TreeList
  • Datasource
  • gridview
  • CheckEdit
  • 전체 선택
  • Chart
  • Await
  • winform
  • LookUpEdit
  • DataGridView
  • ComboBox
  • ComboBoxEdit
  • c#
  • PostgreSQL
  • BAR
  • database
  • task
  • RepositoryGridLookUpEdit
  • 비동기
more
«   2021/01   »
일 월 화 수 목 금 토
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
글 보관함
  • 2020/12 (1)
  • 2020/11 (3)
  • 2020/06 (2)
  • 2020/03 (1)
  • 2020/01 (3)

Blog is powered by Tistory / Designed by Tistory

티스토리툴바