[BackGroundWorkerTEST] Sync , Async , Thread





주요 Code




MSDN
http://msdn.microsoft.com/ko-kr/library/system.componentmodel.backgroundworker(v=VS.90).aspx?appId=Dev10IDEF1&l=KO-KR&k=k(EHINVALIDOPERATION.WINFORMS.ILLEGALCROSSTHREADCALL);k(TargetFrameworkMoniker-".NETFRAMEWORK&k=VERSION=V3.5");k(DevLang-CSHARP)&rd=true




Created with colorer-take5 library. Type 'csharp'

//sync
        private void testCodeSync()
        {
            using (System.Net.WebClient wc = new System.Net.WebClient())
            {
                wc.DownloadFile(streamPath, "test_"+checkTime.ToString()+currentState+".tmp");
            }
            stateTx.Text = currentState + " :: done";
        }


        //async
        private void testCodeAsync()
        {
            using (System.Net.WebClient wc = new System.Net.WebClient())
            {
                wc.DownloadFileAsync(streamPath, "test_" + checkTime.ToString() + currentState + ".tmp");
            }
            stateTx.Text = currentState + " :: done";
        }
        

        
        //################
        //backgroundworker
        BackgroundWorker bw = new BackgroundWorker();
        void BGWorker()
        {
            //bw = new BackgroundWorker();
            bw.RunWorkerAsync();
            bw.DoWork += new DoWorkEventHandler(bw_DoWork);
            bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
        }
        

        void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            //RunWorkerCompleted 이벤트 안에서는 윈폼 스레드로 돌아와 안전��게 컨트롤 할�� 있다.
            stateTx.Text = currentState + " :: done";
            bw.Dispose();
        }

        void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            using (System.Net.WebClient wc = new System.Net.WebClient())
            {
                wc.DownloadFile(streamPath, "test_" + checkTime.ToString() + currentState + ".tmp");
            }
            //에러! : 크로스 스레딩 ( 스레드가 다르다 )
            //stateTx.Text = currentState + " :: done";
        }
인터넷 속도가 빠를경우 테스트가 잘 되지 않지만 Async 도 처음에 실행할때는 약간의 딜레이가 생긴다
sync 는 항상 딜레이가 생긴다.
테스트 타겟은 구글의 메인페이지 이다.
Yamecoder 야매코더_
C# 2010. 12. 4. 02:26

댓글을 달아 주세요

  1. 이전 댓글 더보기
  2. BlogIcon Fitflop NZ Sale Online 2014.10.14 18:14  수정/삭제  댓글쓰기

    이용약관위배로 관리자 삭제된 댓글입니다.

  3. BlogIcon meizitang botanical slimming 2014.10.23 13:50  수정/삭제  댓글쓰기

    이용약관위배로 관리자 삭제된 댓글입니다.

  4. BlogIcon meizitang 2014.10.28 12:29  수정/삭제  댓글쓰기

    이용약관위배로 관리자 삭제된 댓글입니다.

  5. BlogIcon mont blanc fountain pen��mont blanc pen��mont blanc pens��mont b 2014.10.28 12:30  수정/삭제  댓글쓰기

    이용약관위배로 관리자 삭제된 댓글입니다.

  6. BlogIcon Buy macbook pro from china 2014.11.01 21:28  수정/삭제  댓글쓰기

    이용약관위배로 관리자 삭제된 댓글입니다.

  7. BlogIcon burberry shawl 2014.11.01 23:27  수정/삭제  댓글쓰기

    이용약관위배로 관리자 삭제된 댓글입니다.

  8. BlogIcon moncler flavienne quilted jacket 2014.11.09 10:36  수정/삭제  댓글쓰기

    이용약관위배로 관리자 삭제된 댓글입니다.

  9. BlogIcon 眼镜批发 2014.11.12 00:50  수정/삭제  댓글쓰기

    이용약관위배로 관리자 삭제된 댓글입니다.

  10. BlogIcon Buy Samsung Phones 2014.11.12 03:16  수정/삭제  댓글쓰기

    이용약관위배로 관리자 삭제된 댓글입니다.

  11. BlogIcon moncler 70 tal 2014.11.12 11:44  수정/삭제  댓글쓰기

    이용약관위배로 관리자 삭제된 댓글입니다.

  12. BlogIcon moncler bambino shop online 2014.11.12 11:46  수정/삭제  댓글쓰기

    이용약관위배로 관리자 삭제된 댓글입니다.

  13. 匿名 2015.01.07 17:45  수정/삭제  댓글쓰기

    이용약관위배로 관리자 삭제된 댓글입니다.

  14. 匿名 2015.02.06 14:13  수정/삭제  댓글쓰기

    데니冒险岛服务端奇迹mu服务端传奇外传服务端风云无双服务端神迹服务端

    英雄王座travia服务端暗黑修仙服务端仙境传说ro服务端弹弹堂服务端

    蜀门服务端RF服务端丝路传说服务端倚天2服务端决战服务端征服-SF端


    传奇私服开服一条龙开区服务-

    魔域私服一条龙开区服务-


    传奇广告代理-

    IDC服务器以及空间租用-

    破天私服开服一条龙服务-


    客服咨询QQ(企鹅扣扣)1124999543

    Email:1124999543@qq.com

    更多商业版本免费开放下载




    遨腾科技梦幻真彩5D堡垒王国玛法战场韩国连击版传奇服务端



    遨腾科技新传奇全新3D界面装备打孔座骑技能镶嵌宝石英雄合击特别版传奇服务端



    遨腾科技已开5区独家传承宝盒2.06装备精炼属性转移特色赌神轻变升级版传奇服务端



    에런

  15. BlogIcon clubmaster Sunglasses 2015.03.05 17:04  수정/삭제  댓글쓰기

    다없the best way we'd like most efficientmedical attentidirectly to stick fitand fit same way our pets also desirecare, medical attention and prefer to stick fitand fit. additionally they get illness and disease hence additionally they require smartdoctors specialized to offer them hospital therapy. Doctors who're specialized in giving hospital therapy and attentidirectly to animals are referred to as그있

  16. 匿名 2015.03.31 08:50  수정/삭제  댓글쓰기

    단에Another challenge is of course the selection of the fastest checkout line in the supermarket, a feat that requires a vast array of skills and experience combining the assessment of shopper behavior (cash vs. check,Popular Shopping Destinations, self bagging vs. the delegation of bagging, possession of a store discount card vs. the often fictionalized "my spouse has the store discount card"), the k는없

  17. 匿名 2015.04.01 06:28  수정/삭제  댓글쓰기

    방일Black and military green. Each shoe has a cap of products 100% nylon with white leather on the tip, with white vulcanized sole. The following is a list detailing details log on to Nike Air Max 90.



    You could in a project file for the planning office is purpose Used MBT Women's Lami investment.Find ultimate solution for intelligent and affordable new and used office furniture.


    Quite ofte법법

  18. 匿名 2015.04.03 13:49  수정/삭제  댓글쓰기

    가메They are comfortable and keep your feet feel different! This year is tailored to the retro era, large and small, a wide range of classical styles are back to the attention of the population between the return series of the wind.



    Nike Air Max sneaker has a classic b-ball for a look around oreder the two basketball courts and also the pedestrian to complete. Nike Air Max 95, a draft model Spo수메

  19. 匿名 2015.04.03 17:37  수정/삭제  댓글쓰기

    있선Security Headaches



    O.K., so the iPad really won't reduce any costs in my business. Can we justify its business ROI through increased employee productivity? Ha! You try using one of those things for a few hours and then tell me how much actual work you accomplished. It's just too damn fun.



    Clients are going to ask me why I don't recommend it for their business. My employees are going 어알

  20. 匿名 2015.04.04 02:54  수정/삭제  댓글쓰기

    다방火车采集器html简单模板示范






    Fulfill Your Pocket Bike Desires with Mini Chopper Bikes







    [标签:来源]








    There are those among us who collect big toys not just for the sake of displaying them, but also of enjoying them to the fullest. Pocket bikes,How to Read a Woman's Body La, for example, are there to be ridden and seen in public in,Online Shopping- Choosing Awe, and customi관알

  21. 匿名 2015.04.09 00:24  수정/삭제  댓글쓰기

    서방Like the above, knitted hat and a jacket with a lining seam searsucker-like. We're not normally a heavy logo'd pieces, but the embroidered letters feels like a part of the winter-generic design.



    Few have left thoughts about the current collection. Moncler is not for everyone because not everyone can come from the look of nyloned painted in a bright color, but there are some interesting piec일있

Powerd by Tistory, designed by criuce
rss