<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>program1472 &amp;gt; 자료실 &amp;gt; C#</title>
<link>http://assets.program1472.com/bbs/board.php?bo_table=TB_06</link>
<language>ko</language>
<description>C# (2022-09-30 14:36:24)</description>

<item>
<title>[C#] DataGridView 홀수/짝수열 배경색 다르게 지정</title>
<link>http://assets.program1472.com/bbs/board.php?bo_table=TB_06&amp;amp;wr_id=11</link>
<description><![CDATA[<div></div><div style="padding:0 6px;white-space:pre;line-height:130%;">            <span style="color:#a71d5d;">for</span> (<span style="color:#a71d5d;">int</span> i <span style="color:#0086b3;"></span><span style="color:#a71d5d;">=</span> <span style="color:#0099cc;">1</span>; i <span style="color:#0086b3;"></span><span style="color:#a71d5d;">&lt;</span> <span style="color:#a71d5d;">this</span>.Rows.Count; i<span style="color:#0086b3;"></span><span style="color:#a71d5d;">+</span><span style="color:#0086b3;"></span><span style="color:#a71d5d;">+</span>)</div><div style="padding:0 6px;white-space:pre;line-height:130%;">            {</div><div style="padding:0 6px;white-space:pre;line-height:130%;">                <span style="color:#a71d5d;">if</span> (i % <span style="color:#0099cc;">2</span> <span style="color:#0086b3;"></span><span style="color:#a71d5d;">!</span><span style="color:#0086b3;"></span><span style="color:#a71d5d;">=</span> <span style="color:#0099cc;">0</span>)</div><div style="padding:0 6px;white-space:pre;line-height:130%;">                {</div><div style="padding:0 6px;white-space:pre;line-height:130%;">                    <span style="color:#a71d5d;">this</span>.Rows[i].DefaultCellStyle.BackColor <span style="color:#0086b3;"></span><span style="color:#a71d5d;">=</span> Color.FromArgb(<span style="color:#0099cc;">240</span>, <span style="color:#0099cc;">255</span>, <span style="color:#0099cc;">240</span>);</div><div style="padding:0 6px;white-space:pre;line-height:130%;">                }</div><div style="padding:0 6px;white-space:pre;line-height:130%;">                <span style="color:#a71d5d;">else</span></div><div style="padding:0 6px;white-space:pre;line-height:130%;">                {</div><div style="padding:0 6px;white-space:pre;line-height:130%;">                    <span style="color:#a71d5d;">this</span>.Rows[i].DefaultCellStyle.BackColor <span style="color:#0086b3;"></span><span style="color:#a71d5d;">=</span> Color.White;</div><div style="padding:0 6px;white-space:pre;line-height:130%;">                }</div><div style="padding:0 6px;white-space:pre;line-height:130%;">            }</div><div></div>]]></description>
<dc:creator>하나를하더라도최선을</dc:creator>
<dc:date>2022-09-30T14:36:24+09:00</dc:date>
</item>


<item>
<title>C# 개발/폴더 선택 창</title>
<link>http://assets.program1472.com/bbs/board.php?bo_table=TB_06&amp;amp;wr_id=10</link>
<description><![CDATA[<div></div><h1 class="firstHeading" lang="ko" style="font-family:sans-serif;margin:0px 0px 0.25em;padding:0px;border-bottom:1px solid rgb(162,169,177);font-size:1.8em;font-weight:normal;line-height:1.3;" xml:lang="ko">C# 개발/폴더 선택 창</h1><div class="mw-body-content" style="font-family:'나눔고딕', '맑은 고딕', NanumGothic, 'Malgun Gothic';line-height:1.6;color:rgb(32,33,34);"><div style="font-size:11.76px;line-height:1.2em;margin:0px 0px 1.4em 1em;color:rgb(84,89,93);width:auto;"><span class="subpages">&lt; <a href="https://astrawiki.asv.kr/wiki/CSharp_%EA%B0%9C%EB%B0%9C" title="CSharp 개발" style="color:rgb(6,69,173);background-image:none;background-size:initial;" rel="nofollow">CSharp 개발</a></span></div><div style="font-size:11.76px;line-height:1.2em;margin:0px 0px 1.4em 1em;color:rgb(84,89,93);width:auto;"></div><div></div><a class="mw-jump-link" href="https://astrawiki.asv.kr/wiki/CSharp_%EA%B0%9C%EB%B0%9C/%ED%8F%B4%EB%8D%94_%EC%84%A0%ED%83%9D_%EC%B0%BD#mw-head" style="color:rgb(6,69,173);background-image:none;background-size:initial;width:1px;height:1px;margin:-1px;border:0px;padding:0px;" rel="nofollow">둘러보기로 가기</a><a class="mw-jump-link" href="https://astrawiki.asv.kr/wiki/CSharp_%EA%B0%9C%EB%B0%9C/%ED%8F%B4%EB%8D%94_%EC%84%A0%ED%83%9D_%EC%B0%BD#searchInput" style="color:rgb(6,69,173);background-image:none;background-size:initial;width:1px;height:1px;margin:-1px;border:0px;padding:0px;" rel="nofollow">검색하러 가기</a><div lang="ko" dir="ltr" class="mw-content-ltr" style="font-size:1.375rem;" xml:lang="ko"><div class="mw-parser-output"><div class="toc" style="font-size:20.9px;border:1px solid rgb(162,169,177);background-color:rgb(248,249,250);padding:7px;"><div class="toctitle" lang="ko" dir="ltr" style="text-align:center;" xml:lang="ko"><h2 style="font-family:sans-serif;color:rgb(0,0,0);margin:1.2em 0px 0.25em;padding:0px;border:0px;font-size:1.8em;line-height:1.3;">목차</h2><span class="toctogglespan" style="font-size:19.646px;"></span></div><ul style="list-style-image:none;margin:0.3em 0px;padding:0px;list-style-type:none;"><li class="toclevel-1 tocsection-1" style="margin-bottom:0.1em;"><a href="https://astrawiki.asv.kr/wiki/CSharp_%EA%B0%9C%EB%B0%9C/%ED%8F%B4%EB%8D%94_%EC%84%A0%ED%83%9D_%EC%B0%BD#.EA.B0.9C.EC.9A.94" style="color:rgb(6,69,173);background:none;" rel="nofollow"><span class="tocnumber" style="text-decoration:inherit;color:rgb(32,33,34);padding-left:0px;padding-right:0.5em;">1</span><span class="toctext" style="text-decoration:inherit;">개요</span></a></li><li class="toclevel-1 tocsection-2" style="margin-bottom:0.1em;"><a href="https://astrawiki.asv.kr/wiki/CSharp_%EA%B0%9C%EB%B0%9C/%ED%8F%B4%EB%8D%94_%EC%84%A0%ED%83%9D_%EC%B0%BD#.ED.8F.B4.EB.8D.94_.EC.84.A0.ED.83.9D" style="color:rgb(6,69,173);background:none;" rel="nofollow"><span class="tocnumber" style="text-decoration:inherit;color:rgb(32,33,34);padding-left:0px;padding-right:0.5em;">2</span><span class="toctext" style="text-decoration:inherit;">폴더 선택</span></a><ul style="list-style-image:none;margin:0px 0px 0px 2em;padding:0px;list-style-type:none;"><li class="toclevel-2 tocsection-3" style="margin-bottom:0.1em;"><a href="https://astrawiki.asv.kr/wiki/CSharp_%EA%B0%9C%EB%B0%9C/%ED%8F%B4%EB%8D%94_%EC%84%A0%ED%83%9D_%EC%B0%BD#FolderBrowserDialog_.EC.9D.B4.EC.9A.A9" style="color:rgb(6,69,173);background:none;" rel="nofollow"><span class="tocnumber" style="text-decoration:inherit;color:rgb(32,33,34);padding-left:0px;padding-right:0.5em;">2.1</span><span class="toctext" style="text-decoration:inherit;">FolderBrowserDialog 이용</span></a></li><li class="toclevel-2 tocsection-4" style="margin-bottom:0.1em;"><a href="https://astrawiki.asv.kr/wiki/CSharp_%EA%B0%9C%EB%B0%9C/%ED%8F%B4%EB%8D%94_%EC%84%A0%ED%83%9D_%EC%B0%BD#CommonOpenFileDialog_.EC.9D.B4.EC.9A.A9" style="color:rgb(6,69,173);background:none;" rel="nofollow"><span class="tocnumber" style="text-decoration:inherit;color:rgb(32,33,34);padding-left:0px;padding-right:0.5em;">2.2</span><span class="toctext" style="text-decoration:inherit;">CommonOpenFileDialog 이용</span></a></li></ul></li><li class="toclevel-1 tocsection-5" style="margin-bottom:0.1em;"><a href="https://astrawiki.asv.kr/wiki/CSharp_%EA%B0%9C%EB%B0%9C/%ED%8F%B4%EB%8D%94_%EC%84%A0%ED%83%9D_%EC%B0%BD#.ED.8F.B4.EB.8D.94_.EC.97.B4.EA.B8.B0_.28.ED.83.90.EC.83.89.EA.B8.B0_.EC.97.B4.EA.B8.B0.29" style="color:rgb(6,69,173);background:none;" rel="nofollow"><span class="tocnumber" style="text-decoration:inherit;color:rgb(32,33,34);padding-left:0px;padding-right:0.5em;">3</span><span class="toctext" style="text-decoration:inherit;">폴더 열기 (탐색기 열기)</span></a></li><li class="toclevel-1 tocsection-6" style="margin-bottom:0.1em;"><a href="https://astrawiki.asv.kr/wiki/CSharp_%EA%B0%9C%EB%B0%9C/%ED%8F%B4%EB%8D%94_%EC%84%A0%ED%83%9D_%EC%B0%BD#.ED.8C.8C.EC.9D.BC_.EC.A0.80.EC.9E.A5_.EB.8B.A4.EC.9D.B4.EC.95.8C.EB.A1.9C.EA.B7.B8_SaveFileDialog" style="color:rgb(6,69,173);background:none;" rel="nofollow"><span class="tocnumber" style="text-decoration:inherit;color:rgb(32,33,34);padding-left:0px;padding-right:0.5em;">4</span><span class="toctext" style="text-decoration:inherit;">파일 저장 다이알로그 SaveFileDialog</span></a></li><li class="toclevel-1 tocsection-7" style="margin-bottom:0.1em;"><a href="https://astrawiki.asv.kr/wiki/CSharp_%EA%B0%9C%EB%B0%9C/%ED%8F%B4%EB%8D%94_%EC%84%A0%ED%83%9D_%EC%B0%BD#.EC.B0.B8.EC.A1.B0" style="color:rgb(6,69,173);background:none;" rel="nofollow"><span class="tocnumber" style="text-decoration:inherit;color:rgb(32,33,34);padding-left:0px;padding-right:0.5em;">5</span><span class="toctext" style="text-decoration:inherit;">참조</span></a></li></ul></div><h2 style="font-family:sans-serif;color:rgb(0,0,0);margin:1.2em 0px 0.25em;padding:0px;border-bottom:1px solid rgb(162,169,177);font-size:1.8em;font-weight:normal;line-height:1.3;"><span style="font-family:'나눔고딕', '맑은 고딕', NanumGothic, 'Malgun Gothic';"></span><span class="mw-headline" style="font-family:'나눔고딕', '맑은 고딕', NanumGothic, 'Malgun Gothic';">개요</span></h2><h2 style="font-family:sans-serif;color:rgb(0,0,0);margin:1.2em 0px 0.25em;padding:0px;border-bottom:1px solid rgb(162,169,177);font-size:1.8em;font-weight:normal;line-height:1.3;"><span style="font-family:'나눔고딕', '맑은 고딕', NanumGothic, 'Malgun Gothic';"></span><span class="mw-headline" style="font-family:'나눔고딕', '맑은 고딕', NanumGothic, 'Malgun Gothic';">폴더 선택</span></h2><h3 style="color:rgb(0,0,0);margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-bottom:0px;font-size:1.58em;line-height:1.6;margin-top:0.3em;"><span></span><span class="mw-headline">FolderBrowserDialog 이용</span></h3><p style="margin-top:0.5em;margin-bottom:0.5em;">기본으로 내장되어있는 FolderBrowserDialog 사용법이다.</p><div class="mw-highlight mw-highlight-lang-c# mw-content-ltr" dir="ltr" style="font-size:0.875rem;background-size:initial;"><pre style="font-family:monospace, monospace;line-height:1.3;color:rgb(0,0,0);background-color:rgb(248,249,250);border:1px solid rgb(234,236,240);padding:1em;white-space:pre-wrap;"><span class="k" style="color:rgb(0,128,0);font-weight:bold;">private</span> <span class="kt" style="color:rgb(176,0,64);">string</span> <span class="nf" style="color:rgb(0,0,255);">FolderBrowser</span><span class="p">()</span>


<span class="p">{</span>


	<span class="k" style="color:rgb(0,128,0);font-weight:bold;">using</span> <span class="p">(</span><span class="n">FolderBrowserDialog</span> <span class="n">dlg</span> <span class="p">=</span> <span class="k" style="color:rgb(0,128,0);font-weight:bold;">new</span> <span class="n">FolderBrowserDialog</span><span class="p">())</span>


	<span class="p">{</span>


		<span class="n">dlg</span><span class="p">.</span><span class="n">ShowNewFolderButton</span> <span class="p">=</span> <span class="k" style="color:rgb(0,128,0);font-weight:bold;">true</span><span class="p">;</span>


		<span class="n">dlg</span><span class="p">.</span><span class="n">RootFolder</span> <span class="p">=</span> <span class="n">Environment</span><span class="p">.</span><span class="n">SpecialFolder</span><span class="p">.</span><span class="n">MyComputer</span><span class="p">;</span>


		<span class="k" style="color:rgb(0,128,0);font-weight:bold;">if</span><span class="p">(</span><span class="n">dlg</span><span class="p">.</span><span class="n">ShowDialog</span><span class="p">()</span> <span class="p">==</span> <span class="n">DialogResult</span><span class="p">.</span><span class="n">OK</span><span class="p">)</span>


		<span class="p">{</span>


			<span class="c1" style="color:rgb(64,128,128);font-style:italic;">//string path = dlg.SelectedPath;</span>


			<span class="k" style="color:rgb(0,128,0);font-weight:bold;">return</span> <span class="n">dlg</span><span class="p">.</span><span class="n">SelectedPath</span><span class="p">;</span>


		<span class="p">}</span>


	<span class="p">}</span>


	<span class="k" style="color:rgb(0,128,0);font-weight:bold;">return</span> <span class="s" style="color:rgb(186,33,33);">""</span><span class="p">;</span>


<span class="p">}</span>


</pre></div><p style="margin-top:0.5em;margin-bottom:0.5em;"><br /></p><h3 style="color:rgb(0,0,0);margin:1.2em 0px 0px;padding-top:0px;padding-bottom:0px;font-size:1.58em;line-height:1.6;"><span></span><span class="mw-headline">CommonOpenFileDialog 이용</span></h3><p style="margin-top:0.5em;margin-bottom:0.5em;">CommonOpenFileDialog</p><ul style="list-style-image:url(&quot;/w/skins/Vector/resources/skins.vector.styles/images/bullet-icon.svg?d4515&quot;);margin:0.3em 0px 0px 1.6em;padding:0px;"><li style="margin-bottom:0.1em;"><a target="_blank" class="external free" href="https://github.com/aybe/Windows-API-Code-Pack-1.1" style="color:rgb(51,102,187);background-position:right center;padding-right:13px;" rel="nofollow noreferrer noopener">https://github.com/aybe/Windows-API-Code-Pack-1.1</a></li><li style="margin-bottom:0.1em;"><a target="_blank" class="external free" href="https://stackoverflow.com/questions/11624298/how-to-use-openfiledialog-to-select-a-folder" style="color:rgb(51,102,187);background-position:right center;padding-right:13px;" rel="nofollow noreferrer noopener">https://stackoverflow.com/questions/11624298/how-to-use-openfiledialog-to-select-a-folder</a></li></ul><p style="margin-top:0.5em;margin-bottom:0.5em;">기본형태인 FolderBrowserDialog 가 기능이 부실해서, 대안으로 이용되는 방법이다. 파일열기 와 비슷한 형태로 폴더를 선택할 때 이용된다.</p><p style="margin-top:0.5em;margin-bottom:0.5em;">마이크로소프트 에서 만들었으며 현재는 더이상 관리되지 않음. 'Free to use' 였으므로 'Aybe' 라는 사람이 Github 에 올리고 관리하는 듯 하다. 이것을 NuGet 으로 다운받을 수 있다. 이런 연유로 패키지명이 Microsoft.WindowsAPICodePack 이다.</p><p style="margin-top:0.5em;margin-bottom:0.5em;"><br />1. 셋팅 방법-1 (예전 방법) 다음을 다운로드 받고, 2개의 어셈블리 추가.</p><ul style="list-style-image:url(&quot;/w/skins/Vector/resources/skins.vector.styles/images/bullet-icon.svg?d4515&quot;);margin:0.3em 0px 0px 1.6em;padding:0px;"><li style="margin-bottom:0.1em;">Windows® API Code Pack for Microsoft® .NET Framework</li><li style="margin-bottom:0.1em;"><a target="_blank" class="external free" href="http://archive.msdn.microsoft.com/WindowsAPICodePack/" style="color:rgb(51,102,187);background-position:right center;padding-right:13px;" rel="nofollow noreferrer noopener">http://archive.msdn.microsoft.com/WindowsAPICodePack/</a></li><li style="margin-bottom:0.1em;">해당 어셈블리<ul style="list-style-image:url(&quot;/w/skins/Vector/resources/skins.vector.styles/images/bullet-icon.svg?d4515&quot;);margin:0.3em 0px 0px 1.6em;padding:0px;"><li style="margin-bottom:0.1em;">Microsoft.WindowsAPICodePack.dll</li><li style="margin-bottom:0.1em;">Microsoft.WindowsAPICodePack.Shell.dll</li></ul></li></ul><p style="margin-top:0.5em;margin-bottom:0.5em;">2. 셋팅방법-2 (NuGet 이용)</p><ul style="list-style-image:url(&quot;/w/skins/Vector/resources/skins.vector.styles/images/bullet-icon.svg?d4515&quot;);margin:0.3em 0px 0px 1.6em;padding:0px;"><li style="margin-bottom:0.1em;">도구 &gt; NuGet 패키지 관리자 &gt; 솔루션용 NuGet 패키지 관리</li><li style="margin-bottom:0.1em;"><code style="font-family:monospace, monospace;color:rgb(0,0,0);background-color:rgb(248,249,250);border:1px solid rgb(234,236,240);padding:1px 4px;">WindowsAPICodePack-Shell</code> 를 선택, 설치.</li></ul><p style="margin-top:0.5em;margin-bottom:0.5em;"><br />사용</p><div class="mw-highlight mw-highlight-lang-c# mw-content-ltr" dir="ltr" style="font-size:0.875rem;background-size:initial;"><pre style="font-family:monospace, monospace;line-height:1.3;color:rgb(0,0,0);background-color:rgb(248,249,250);border:1px solid rgb(234,236,240);padding:1em;white-space:pre-wrap;"><span class="kt" style="color:rgb(176,0,64);">var</span> <span class="n">dialog</span> <span class="p">=</span> <span class="k" style="color:rgb(0,128,0);font-weight:bold;">new</span> <span class="n">CommonOpenFileDialog</span><span class="p">();</span>


<span class="n">dialog</span><span class="p">.</span><span class="n">IsFolderPicker</span> <span class="p">=</span> <span class="k" style="color:rgb(0,128,0);font-weight:bold;">true</span><span class="p">;</span>


<span class="k" style="color:rgb(0,128,0);font-weight:bold;">if</span> <span class="p">(</span><span class="n">dialog</span><span class="p">.</span><span class="n">ShowDialog</span><span class="p">()</span> <span class="p">==</span> <span class="n">CommonFileDialogResult</span><span class="p">.</span><span class="n">Ok</span><span class="p">)</span>


<span class="p">{</span>


    <span class="k" style="color:rgb(0,128,0);font-weight:bold;">this</span><span class="p">.</span><span class="n">Path</span> <span class="p">=</span> <span class="n">dialog</span><span class="p">.</span><span class="n">FileName</span><span class="p">;</span>


<span class="p">}</span>


</pre></div><p style="margin-top:0.5em;margin-bottom:0.5em;"><br />배포할 때는 다음을 포함한다.</p><ul style="list-style-image:url(&quot;/w/skins/Vector/resources/skins.vector.styles/images/bullet-icon.svg?d4515&quot;);margin:0.3em 0px 0px 1.6em;padding:0px;"><li style="margin-bottom:0.1em;">Microsoft.WindowsAPICodePack.dll</li><li style="margin-bottom:0.1em;">Microsoft.WindowsAPICodePack.Shell.dll</li><li style="margin-bottom:0.1em;">Microsoft.WindowsAPICodePack.Shell.xml</li><li style="margin-bottom:0.1em;">Microsoft.WindowsAPICodePack.xml</li></ul><h2 style="font-family:sans-serif;color:rgb(0,0,0);margin:1.2em 0px 0.25em;padding:0px;border-bottom:1px solid rgb(162,169,177);font-size:1.8em;font-weight:normal;line-height:1.3;"><span style="font-family:'나눔고딕', '맑은 고딕', NanumGothic, 'Malgun Gothic';"></span><span class="mw-headline" style="font-family:'나눔고딕', '맑은 고딕', NanumGothic, 'Malgun Gothic';">폴더 열기 (탐색기 열기)</span></h2><p style="margin-top:0.5em;margin-bottom:0.5em;">탐색기 열기</p><div class="mw-highlight mw-highlight-lang-c# mw-content-ltr" dir="ltr" style="font-size:0.875rem;background-size:initial;"><pre style="font-family:monospace, monospace;line-height:1.3;color:rgb(0,0,0);background-color:rgb(248,249,250);border:1px solid rgb(234,236,240);padding:1em;white-space:pre-wrap;"><span class="n">System</span><span class="p">.</span><span class="n">Diagnostics</span><span class="p">.</span><span class="n">Process</span><span class="p">.</span><span class="n">Start</span><span class="p">(</span><span class="s" style="color:rgb(186,33,33);">"explorer.exe"</span><span class="p">,</span> <span class="n">path</span><span class="p">);</span>


</pre></div><p style="margin-top:0.5em;margin-bottom:0.5em;"><br /></p><h2 style="font-family:sans-serif;color:rgb(0,0,0);margin:1.2em 0px 0.25em;padding:0px;border-bottom:1px solid rgb(162,169,177);font-size:1.8em;font-weight:normal;line-height:1.3;"><span style="font-family:'나눔고딕', '맑은 고딕', NanumGothic, 'Malgun Gothic';"></span><span class="mw-headline" style="font-family:'나눔고딕', '맑은 고딕', NanumGothic, 'Malgun Gothic';">파일 저장 다이알로그 SaveFileDialog</span></h2><div class="mw-highlight mw-highlight-lang-c# mw-content-ltr" dir="ltr" style="font-size:0.875rem;background-size:initial;"><pre style="font-family:monospace, monospace;line-height:1.3;color:rgb(0,0,0);background-color:rgb(248,249,250);border:1px solid rgb(234,236,240);padding:1em;white-space:pre-wrap;"><span class="k" style="color:rgb(0,128,0);font-weight:bold;">public</span> <span class="kt" style="color:rgb(176,0,64);">bool</span> <span class="nf" style="color:rgb(0,0,255);">DoSaveFileDialog</span><span class="p">(</span><span class="n">Image</span> <span class="n">image</span><span class="p">)</span>


<span class="p">{</span>


	<span class="kt" style="color:rgb(176,0,64);">string</span> <span class="n">filePath</span> <span class="p">=</span> <span class="s" style="color:rgb(186,33,33);">""</span><span class="p">;</span>


	<span class="k" style="color:rgb(0,128,0);font-weight:bold;">using</span> <span class="p">(</span><span class="n">SaveFileDialog</span> <span class="n">dlg</span> <span class="p">=</span> <span class="k" style="color:rgb(0,128,0);font-weight:bold;">new</span> <span class="n">SaveFileDialog</span><span class="p">())</span>


	<span class="p">{</span>


		<span class="n">dlg</span><span class="p">.</span><span class="n">Title</span> <span class="p">=</span> <span class="s" style="color:rgb(186,33,33);">"이미지 저장"</span><span class="p">;</span><span class="c1" style="color:rgb(64,128,128);font-style:italic;">//창위에 뜨는 타이틀</span>


		<span class="n">dlg</span><span class="p">.</span><span class="n">FileName</span> <span class="p">=</span> <span class="n">GenerateBaseFilename</span><span class="p">();</span>


		<span class="n">dlg</span><span class="p">.</span><span class="n">Filter</span> <span class="p">=</span> <span class="s" style="color:rgb(186,33,33);">"PNG 이미지 (*.png)|*.png|JPG 이미지 (*.jpg)|*.jpg|BMP 이미지 (*.bmp)|*.bmp|GIF 이미지 (*.gif)|*.gif|모든 파일 (*.*)|*.*"</span><span class="p">;</span><span class="c1" style="color:rgb(64,128,128);font-style:italic;">//확장자 선택</span>


		<span class="n">dlg</span><span class="p">.</span><span class="n">DefaultExt</span> <span class="p">=</span> <span class="s" style="color:rgb(186,33,33);">"png"</span><span class="p">;</span>


		<span class="n">dlg</span><span class="p">.</span><span class="n">InitialDirectory</span> <span class="p">=</span> <span class="s" style="color:rgb(186,33,33);">""</span><span class="p">;</span>





		<span class="c1" style="color:rgb(64,128,128);font-style:italic;">//showDialog의 리턴값이 OK 일 때</span>


		<span class="k" style="color:rgb(0,128,0);font-weight:bold;">if</span> <span class="p">(</span><span class="n">dlg</span><span class="p">.</span><span class="n">ShowDialog</span><span class="p">()</span> <span class="p">==</span> <span class="n">DialogResult</span><span class="p">.</span><span class="n">OK</span><span class="p">)</span>


		<span class="p">{</span>


			<span class="n">filePath</span> <span class="p">=</span> <span class="n">dlg</span><span class="p">.</span><span class="n">FileName</span><span class="p">;</span>


		<span class="p">}</span> <span class="k" style="color:rgb(0,128,0);font-weight:bold;">else</span>


		<span class="p">{</span>


			<span class="c1" style="color:rgb(64,128,128);font-style:italic;">// 취소 한 경우</span>


			<span class="k" style="color:rgb(0,128,0);font-weight:bold;">return</span> <span class="k" style="color:rgb(0,128,0);font-weight:bold;">false</span><span class="p">;</span>


		<span class="p">}</span>


	<span class="p">}</span>


	


	<span class="k" style="color:rgb(0,128,0);font-weight:bold;">if</span> <span class="p">(</span><span class="n">filePath</span><span class="p">.</span><span class="n">Trim</span><span class="p">().</span><span class="n">Length</span> <span class="p">&gt;</span> <span class="m" style="color:rgb(102,102,102);">1</span><span class="p">)</span>


	<span class="p">{</span>


		<span class="n">MessageBox</span><span class="p">.</span><span class="n">Show</span><span class="p">(</span><span class="s" style="color:rgb(186,33,33);">"저장 되었습니다."</span><span class="p">);</span>


		<span class="k" style="color:rgb(0,128,0);font-weight:bold;">return</span> <span class="k" style="color:rgb(0,128,0);font-weight:bold;">true</span><span class="p">;</span>


	<span class="p">}</span>


	<span class="k" style="color:rgb(0,128,0);font-weight:bold;">else</span>


	<span class="p">{</span> 


		<span class="c1" style="color:rgb(64,128,128);font-style:italic;">// 경로를 잘못 지정한 경우</span>


		<span class="n">MessageBox</span><span class="p">.</span><span class="n">Show</span><span class="p">(</span><span class="s" style="color:rgb(186,33,33);">"저장경로를 설정해주세요"</span><span class="p">);</span>


	<span class="p">}</span>


	<span class="k" style="color:rgb(0,128,0);font-weight:bold;">return</span> <span class="k" style="color:rgb(0,128,0);font-weight:bold;">false</span><span class="p">;</span>


<span class="p">}</span></pre></div></div></div></div><div></div>]]></description>
<dc:creator>하나를하더라도최선을</dc:creator>
<dc:date>2022-09-22T12:32:51+09:00</dc:date>
</item>


<item>
<title>[C#] ToolStripTextBox에서 Enter 키를 누를 때 ContextMenuStrip 닫기</title>
<link>http://assets.program1472.com/bbs/board.php?bo_table=TB_06&amp;amp;wr_id=9</link>
<description><![CDATA[<div></div><pre class="prettyprint" style="font-family:Menlo, Monaco, Consolas, 'Courier New', monospace;font-size:13px;padding:9.5px;margin-top:0px;margin-bottom:10px;line-height:1.42857;color:rgb(51,51,51);background-color:rgb(245,245,245);border:1px solid rgb(204,204,204);">private void toolStripTextBox1_KeyUp(object sender, KeyEventArgs e) {


    if (e.KeyCode == Keys.Enter) {


        menu.Close();


    }


}</pre><div></div>]]></description>
<dc:creator>하나를하더라도최선을</dc:creator>
<dc:date>2022-01-29T06:53:21+09:00</dc:date>
</item>


<item>
<title>[C#] 웹 이미지를 C# 에서 불러오는 함수</title>
<link>http://assets.program1472.com/bbs/board.php?bo_table=TB_06&amp;amp;wr_id=7</link>
<description><![CDATA[<div style="margin:0;padding:0;color:#010101;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;line-height:130%;"><div style="padding:0 6px;white-space:pre;line-height:130%;"><span style="color:#a71d5d;">public</span> Bitmap WebImageView(<span style="color:#a71d5d;">string</span> URL)</div><div style="padding:0 6px;white-space:pre;line-height:130%;"> </div><div style="padding:0 6px;white-space:pre;line-height:130%;">{</div><div style="padding:0 6px;white-space:pre;line-height:130%;"> </div><div style="padding:0 6px;white-space:pre;line-height:130%;">    <span style="color:#a71d5d;">try</span></div><div style="padding:0 6px;white-space:pre;line-height:130%;"> </div><div style="padding:0 6px;white-space:pre;line-height:130%;">    {</div><div style="padding:0 6px;white-space:pre;line-height:130%;"> </div><div style="padding:0 6px;white-space:pre;line-height:130%;">        <span style="color:#066de2;">WebClient</span> Downloader <span style="color:#0086b3;"></span><span style="color:#a71d5d;">=</span> <span style="color:#a71d5d;">new</span> <span style="color:#066de2;">WebClient</span>();</div><div style="padding:0 6px;white-space:pre;line-height:130%;"> </div><div style="padding:0 6px;white-space:pre;line-height:130%;">        Stream ImageStream <span style="color:#0086b3;"></span><span style="color:#a71d5d;">=</span> Downloader.OpenRead(URL);</div><div style="padding:0 6px;white-space:pre;line-height:130%;"> </div><div style="padding:0 6px;white-space:pre;line-height:130%;">        Bitmap DownloadImage <span style="color:#0086b3;"></span><span style="color:#a71d5d;">=</span> Bitmap.FromStream(ImageStream) <span style="color:#a71d5d;">as</span> Bitmap;</div><div style="padding:0 6px;white-space:pre;line-height:130%;"> </div><div style="padding:0 6px;white-space:pre;line-height:130%;">        <span style="color:#a71d5d;">return</span> DownloadImage;</div><div style="padding:0 6px;white-space:pre;line-height:130%;"> </div><div style="padding:0 6px;white-space:pre;line-height:130%;">    }</div><div style="padding:0 6px;white-space:pre;line-height:130%;"> </div><div style="padding:0 6px;white-space:pre;line-height:130%;">    <span style="color:#a71d5d;">catch</span> (<span style="color:#066de2;">Exception</span>)</div><div style="padding:0 6px;white-space:pre;line-height:130%;"> </div><div style="padding:0 6px;white-space:pre;line-height:130%;">    {</div><div style="padding:0 6px;white-space:pre;line-height:130%;"> </div><div style="padding:0 6px;white-space:pre;line-height:130%;">        <span style="color:#a71d5d;">return</span> <span style="color:#a71d5d;">null</span>;</div><div style="padding:0 6px;white-space:pre;line-height:130%;"> </div><div style="padding:0 6px;white-space:pre;line-height:130%;">    }</div><div style="padding:0 6px;white-space:pre;line-height:130%;"> </div><div style="padding:0 6px;white-space:pre;line-height:130%;">}</div></div><div style="text-align:right;margin-top:-13px;margin-right:5px;font-size:9px;font-style:italic;"></div> ]]></description>
<dc:creator>하나를하더라도최선을</dc:creator>
<dc:date>2020-08-29T16:22:13+09:00</dc:date>
</item>


<item>
<title>[C#] [테스트 검수중] .Net 환경에서 Selenium을 사용하여 모바일 UI 구현</title>
<link>http://assets.program1472.com/bbs/board.php?bo_table=TB_06&amp;amp;wr_id=6</link>
<description><![CDATA[<p style="margin-bottom:1em;border:0px;line-height:inherit;font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;font-size:15px;vertical-align:baseline;clear:both;color:rgb(36,39,41);background-color:rgb(255,255,255);"><span>c #을 사용하는 .Net 환경에서 Selenium을 사용하여 모바일 UI 테스트를하고 있습니다.</span></p><p style="margin-bottom:1em;border:0px;line-height:inherit;font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;font-size:15px;vertical-align:baseline;clear:both;color:rgb(36,39,41);background-color:rgb(255,255,255);"><span>세로 모드에서 크롬 모바일 에뮬레이션을 사용하여 테스트를 성공적으로 수행 할 수 있지만 에뮬레이션을 가로 모드로 설정하는 방법을 찾을 수 없습니다.</span></p><p style="margin-bottom:1em;border:0px;line-height:inherit;font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;font-size:15px;vertical-align:baseline;clear:both;color:rgb(36,39,41);background-color:rgb(255,255,255);"><span>테스트하는 동안 프로그래밍 방식으로 회전하고 싶지만 연구를 통해 아직 불가능한 것으로 보입니다.</span></p><p style="margin-bottom:1em;border:0px;line-height:inherit;font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;font-size:15px;vertical-align:baseline;clear:both;color:rgb(36,39,41);background-color:rgb(255,255,255);"><span>세로 모드로 작업 중입니다.</span></p><pre class="lang-cs prettyprint prettyprinted" style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;line-height:inherit;font-family:Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;font-size:13px;vertical-align:baseline;width:auto;max-height:600px;color:rgb(36,39,41);"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;vertical-align:baseline;white-space:inherit;"><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">        </span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">ChromeOptions</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> chromeCapabilities </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="kwd" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">new</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">ChromeOptions</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">();</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">         





        chromeCapabilities</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">.</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">EnableMobileEmulation</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">(</span><span class="str" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">"Apple iPhone 6"</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">);</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">





        </span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">ChromeDriverService</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> service </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">ChromeDriverService</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">.</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">CreateDefaultService</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">(</span><span class="str" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">@"C:\chromedriver"</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">);</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">            





        </span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">IWebDriver</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> driver </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="kwd" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">new</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">ChromeDriver</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">service</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> chromeCapabilities</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">);</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">


        driver</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">.</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">Navigate</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">().</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">GoToUrl</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">(</span><span class="str" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">"www.google.com"</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">);</span></code></pre><p style="margin-bottom:1em;border:0px;line-height:inherit;font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;font-size:15px;vertical-align:baseline;clear:both;color:rgb(36,39,41);background-color:rgb(255,255,255);"><span>그러나 iPhone 에뮬레이션을 가로 방향으로 어떻게 배치합니까?</span></p><p style="margin-bottom:1em;border:0px;line-height:inherit;font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;font-size:15px;vertical-align:baseline;clear:both;color:rgb(36,39,41);background-color:rgb(255,255,255);"><span>나는 이것을 시도했지만 작동하지 않고 크기 제한없이 브라우저가 열립니다.</span></p><pre class="lang-cs prettyprint prettyprinted" style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;line-height:inherit;font-family:Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;font-size:13px;vertical-align:baseline;width:auto;max-height:600px;color:rgb(36,39,41);"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;vertical-align:baseline;white-space:inherit;"><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">        </span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">ChromeMobileEmulationDeviceSettings</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> CMEDS </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="kwd" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">new</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">ChromeMobileEmulationDeviceSettings</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">();</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">


        CMEDS</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">.</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">Width</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="lit" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">66</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">


        CMEDS</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">.</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">Height</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="lit" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">37</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">


        CMEDS</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">.</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">PixelRatio</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="lit" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">1.0</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">


        CMEDS</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">.</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">UserAgent</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="str" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">"Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">;</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">





        </span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">ChromeOptions</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> chromeCapabilities </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="kwd" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">new</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">ChromeOptions</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">();</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">





        chromeCapabilities</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">.</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">EnableMobileEmulation</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">CMEDS</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">);</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">





        </span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">ChromeDriverService</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> service </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">ChromeDriverService</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">.</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">CreateDefaultService</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">(</span><span class="str" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">@"C:\chromedriver"</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">);</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">





        </span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">IWebDriver</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> driver </span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">=</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="kwd" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">new</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> </span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">ChromeDriver</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">(</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">service</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">,</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;"> chromeCapabilities</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">);</span><span class="pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">


        driver</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">.</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">Navigate</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">().</span><span class="typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(43,145,175);">GoToUrl</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">(</span><span class="str" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">"www.google.com"</span><span class="pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-family:inherit;vertical-align:baseline;">);</span></code></pre><p style="margin-bottom:1em;border:0px;line-height:inherit;font-family:Arial, 'Helvetica Neue', Helvetica, sans-serif;font-size:15px;vertical-align:baseline;clear:both;color:rgb(36,39,41);background-color:rgb(255,255,255);"><span><span>어떤 도움이나 조언도 크게 받았습니다! </span><span>미리 감사드립니다</span></span></p>]]></description>
<dc:creator>하나를하더라도최선을</dc:creator>
<dc:date>2020-05-22T16:10:26+09:00</dc:date>
</item>


<item>
<title>[C#] Webbrowser control(HtmlElement) position(Left, Top)</title>
<link>http://assets.program1472.com/bbs/board.php?bo_table=TB_06&amp;amp;wr_id=5</link>
<description><![CDATA[<div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">   <span style="color:rgb(167,29,93);">public</span> <span style="color:rgb(167,29,93);">int</span> getXoffset(HtmlElement el)</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">     {</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">         <span style="color:rgb(153,153,153);">//get element pos</span></div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">         <span style="color:rgb(167,29,93);">int</span> xPos <span style="color:rgb(0,134,179);"></span><span style="color:rgb(167,29,93);">=</span> el.OffsetRectangle.Left;</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;"> </div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">         <span style="color:rgb(153,153,153);">//get the parents pos</span></div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">         HtmlElement tempEl <span style="color:rgb(0,134,179);"></span><span style="color:rgb(167,29,93);">=</span> el.OffsetParent;</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">         <span style="color:rgb(167,29,93);">while</span> (tempEl <span style="color:rgb(0,134,179);"></span><span style="color:rgb(167,29,93);">!</span><span style="color:rgb(0,134,179);"></span><span style="color:rgb(167,29,93);">=</span> <span style="color:rgb(167,29,93);">null</span>)</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">         {</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">             xPos <span style="color:rgb(0,134,179);"></span><span style="color:rgb(167,29,93);">+</span><span style="color:rgb(0,134,179);"></span><span style="color:rgb(167,29,93);">=</span> tempEl.OffsetRectangle.Left;</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">             tempEl <span style="color:rgb(0,134,179);"></span><span style="color:rgb(167,29,93);">=</span> tempEl.OffsetParent;</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">         }</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;"> </div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">         <span style="color:rgb(167,29,93);">return</span> xPos; </div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">     }  </div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;"> </div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">     <span style="color:rgb(167,29,93);">public</span> <span style="color:rgb(167,29,93);">int</span> getYoffset(HtmlElement el)</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">     {</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">         <span style="color:rgb(153,153,153);">//get element pos</span></div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">         <span style="color:rgb(167,29,93);">int</span> yPos <span style="color:rgb(0,134,179);"></span><span style="color:rgb(167,29,93);">=</span> el.OffsetRectangle.Top;</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;"> </div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">         <span style="color:rgb(153,153,153);">//get the parents pos</span></div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">         HtmlElement tempEl <span style="color:rgb(0,134,179);"></span><span style="color:rgb(167,29,93);">=</span> el.OffsetParent;</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">         <span style="color:rgb(167,29,93);">while</span> (tempEl <span style="color:rgb(0,134,179);"></span><span style="color:rgb(167,29,93);">!</span><span style="color:rgb(0,134,179);"></span><span style="color:rgb(167,29,93);">=</span> <span style="color:rgb(167,29,93);">null</span>)</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">         {</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">             yPos <span style="color:rgb(0,134,179);"></span><span style="color:rgb(167,29,93);">+</span><span style="color:rgb(0,134,179);"></span><span style="color:rgb(167,29,93);">=</span> tempEl.OffsetRectangle.Top;</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">             tempEl <span style="color:rgb(0,134,179);"></span><span style="color:rgb(167,29,93);">=</span> tempEl.OffsetParent;</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">         }</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;"> </div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">         <span style="color:rgb(167,29,93);">return</span> yPos;</div><div style="color:rgb(1,1,1);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;padding:0px 6px;white-space:pre;line-height:15.6px;">     }</div>]]></description>
<dc:creator>하나를하더라도최선을</dc:creator>
<dc:date>2019-11-20T15:07:35+09:00</dc:date>
</item>


<item>
<title>[C#] [펌] '크로스 스레드 작업이 잘못되었습니다' - 넌 왜 나타나서 날 괴롭게 하니..</title>
<link>http://assets.program1472.com/bbs/board.php?bo_table=TB_06&amp;amp;wr_id=4</link>
<description><![CDATA[<p style="text-align:right;" align="right">출처: <a href="https://slaner.tistory.com/45" rel="nofollow">https://slaner.tistory.com/45</a> [꿈꾸는 프로그래머]</p>








<div style="height:auto;"><div style="height:auto;"><div style="height:auto;"><div><h2><a href="/45">'크로스 스레드 작업이 잘못되었습니다' - 넌 왜 나타나서 날 괴롭게 하니..</a></h2><div class="date">2014.09.29 20:21</div></div><div class="entry" style="height:auto;"><div class="tag_label"><span><a href="/tag/C%23">C#</a>,


<a href="/tag/Cross%20Thread">Cross Thread</a>,


<a href="/tag/InvalidOperationException">InvalidOperationException</a>,


<a href="/tag/INVOKE">INVOKE</a>,


<a href="/tag/InvokeRequired">InvokeRequired</a>,


<a href="/tag/%EB%B9%84%EB%8F%99%EA%B8%B0">비동기</a>,


<a href="/tag/%EB%B9%84%EB%8F%99%EA%B8%B0%20%EC%BB%A8%ED%8A%B8%EB%A1%A4%20%EC%A0%91%EA%B7%BC">비동기 컨트롤 접근</a>,


<a href="/tag/%ED%81%AC%EB%A1%9C%EC%8A%A4%20%EC%8A%A4%EB%A0%88%EB%93%9C">크로스 스레드</a>,


<a href="/tag/%ED%81%AC%EB%A1%9C%EC%8A%A4%20%EC%8A%A4%EB%A0%88%EB%93%9C%20%EC%9E%91%EC%97%85%EC%9D%B4%20%EC%9E%98%EB%AA%BB%EB%90%98%EC%97%88%EC%8A%B5%EB%8B%88%EB%8B%A4">크로스 스레드 작업이 잘못되었습니다</a></span><div class="clear"></div></div><div class="article" style="height:auto;"><div class="tt_article_useless_p_margin"><p>스레드 혹은 비동기 작업의 콜백에서 컨트롤에 접근하면 '크로스 스레드 작업이 잘못되었습니다' 라는 예외 메세지를 받아보신 적이 있으실겁니다. 이 예외는 컨트롤이 만들어진 스레드가 아닌 다른 스레드에서 접근을 했기 때문에 발생하는데요..</p><p>해결 방법은 너무나도 간단합니다.</p><p>원하는 작업을 하는 메서드를 만들고, 컨트롤의 스레드 내에서 실행시키게 하면 끝이죠.</p><p><br /></p><p>저도 소켓을 이용해서 비동기 작업을 하다가 저 예외 메세지를 너무 많이 봤습니다.</p><p>예외가 발생해서, 만들던 프로그램의 진행 상태도 멈춰버렸기 때문에 최대한 빨리 해결해야 했는데, 이런 예외를 보는 사람이 국적없이 너도나도 참 많이 발생하나봅니다.</p><p><br /></p><p>일단, 예외 발생과 어떻게 해결하는지를 보여드리기 위해서 아래와 같은 코드를 작성하였습니다.</p><p>(이 코드는 예외를 발생시킵니다)</p><p class="codetext" style="border:1px solid #ababab;"><span style="color:#008000;font-weight:bold;">using</span> System;<br /><span style="color:#008000;font-weight:bold;">using</span> System.Collections.Generic;<br /><span style="color:#008000;font-weight:bold;">using</span> System.Drawing;<br /><span style="color:#008000;font-weight:bold;">using</span> System.Threading;<br /><span style="color:#008000;font-weight:bold;">using</span> System.Windows.Forms;<br /><span style="color:#008000;font-weight:bold;">namespace</span> CrossThreadSafetyAccess {<br />


    <span style="color:#0000ff;font-weight:bold;">public</span> <span style="color:#000080;">partial</span> <span style="color:#ff0000;">class</span> MainForm : Form {<br />


        <span style="color:#0000ff;font-weight:bold;">public</span> <span style="color:#191970;font-weight:bold;">MainForm</span>() {<br />


            <span style="color:#191970;font-weight:bold;">InitializeComponent</span>();<br />


        }<br />


        <br />


        <span style="color:#0000ff;font-weight:bold;">private</span> <span style="color:#ff0000;">void</span> <span style="color:#191970;font-weight:bold;">Button1Click</span>(<span style="color:#ff0000;">object</span> sender, EventArgs e) {<br />


            Thread t = <span style="color:#008b8b;font-weight:bold;">new</span> <span style="color:#191970;font-weight:bold;">Thread</span>(CrossThreadNonSafetyAccess);<br />


            t.<span style="color:#191970;font-weight:bold;">Start</span>();<br />


        }<br />


        <span style="color:#0000ff;font-weight:bold;">private</span> <span style="color:#ff0000;">void</span> <span style="color:#191970;font-weight:bold;">CrossThreadNonSafetyAccess</span>() {<br />


            <span style="color:#008080;font-weight:bold;">try</span> {<br />


                button1.Text = <span style="color:#0000ff;">"Not safety code"</span>;        <br />


            } <span style="color:#008080;font-weight:bold;">catch</span> (Exception ex) {<br />


                MessageBox.<span style="color:#191970;font-weight:bold;">Show</span>(ex.Message, ex.<span style="color:#191970;font-weight:bold;">GetType</span>().<span style="color:#191970;font-weight:bold;">ToString</span>(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);<br />


            }<br />


        }<br />


    }<br />


}</p><p><br /></p><p>그리고 이 코드를 실행하고, 버튼을 클릭하면 이런 메세지 박스가 나오게 됩니다.</p><p style="text-align:center;clear:none;float:none;"><span class="imageblock" style="width:487px;height:auto;max-width:100%;"><img src="http://program1472.com/data/editor/1909/92cb6b7be821bf83c8ade8220278f2ab_1568814701_9178.jpg" title="92cb6b7be821bf83c8ade8220278f2ab_1568814701_9178.jpg" alt="92cb6b7be821bf83c8ade8220278f2ab_1568814701_9178.jpg" /><br style="clear:both;" /><br /></span></p><p style="text-align:center;clear:none;float:none;"><br /></p><p style="text-align:center;clear:none;float:none;"><br /></p><p>직접 스레드를 만들지 않고도, 이 예외가 발생하는 경우는 많습니다.</p><p>앞서 말씀드린 비동기 소켓의 콜백에서 접근했을 경우라던지, 스레드가 생성되어 독립적으로 처리되는 메서드에서의 접근이라던지..</p><p><br /></p><p><br /></p><p>그럼 이 예외는 어떻게 처리를 할까요?</p><p>처리 방법은 어렵지 않습니다.</p><p>먼저, 접근하려는 속성이나 메서드의 매개 변수와 반환 값을 잘 확인해서 그와 비슷한 대리자를 하나 만듭니다.</p><p>위의 코드의 경우 텍스트를 변경하는 것이기에 저는 대리자를 이렇게 만들었습니다.</p><p class="codetext" style="border:1px solid #ababab;"><span style="color:#ff0000;">delegate</span> <span style="color:#ff0000;">void</span> <span style="color:#191970;font-weight:bold;">CrossThreadSafetySetText</span>(Control ctl, String text);</p><p><br /></p><p>매개 변수로 컨트롤과 문자열을 받는데, 이는 컨트롤의 텍스트를 설정하려고 두 개의 매개 변수를 받은 것입니다.</p><p>그리고, 대리자를 만든 후에는 또 다른 메서드 하나를 만듭니다.</p><p>(이 메서드에서 실질적인 텍스트 설정이 이뤄지게 됩니다)</p><div><p class="codetext" style="border:1px solid #ababab;"><span style="color:#0000ff;font-weight:bold;">private</span> <span style="color:#ff0000;">void</span> <span style="color:#191970;font-weight:bold;">CSafeSetText</span>(Control ctl, String text) {<br />


    <br />


    <span style="color:#008000;">/*</span><br /><span style="color:#008000;">     * InvokeRequired 속성 (<a href="http://msdn.microsoft.com/ko-kr/library/system.windows.forms.control.invokerequired(v=vs.110).aspx" target="_blank" class="tx-link" rel="nofollow noreferrer noopener">Control.InvokeRequired</a>, MSDN)</span><br /><span style="color:#008000;">     *   짧게 말해서, 이 컨트롤이 만들어진 스레드와 현재의 스레드가 달라서</span><br /><span style="color:#008000;">     *   컨트롤에서 스레드를 만들어야 하는지를 나타내는 속성입니다.  </span><br /><span style="color:#008000;">     * </span><br /><span style="color:#008000;">     * InvokeRequired 속성의 값이 참이면, 컨트롤에서 스레드를 만들어 텍스트를 변경하고,</span><br /><span style="color:#008000;">     * 그렇지 않은 경우에는 그냥 변경해도 아무 오류가 없기 때문에 텍스트를 변경합니다.</span><br /><span style="color:#008000;">     */</span><br />


    <span style="color:#0000ff;font-weight:bold;">if</span> ( ctl.InvokeRequired )<br />


        ctl.<span style="color:#191970;font-weight:bold;">Invoke</span>(<span style="color:#008b8b;font-weight:bold;">new</span> <span style="color:#191970;font-weight:bold;">CrossThreadSafetySetText</span>(CSafeSetText), ctl, text);<br />


    <span style="color:#0000ff;font-weight:bold;">else</span><br />


        ctl.Text = text;<br />


}</p></div><p><br /></p><p>위의 메서드에선 CrossThreadSafetySetText 이란 대리자를 CSafeSetText 메서드를 넘겨줌으로써 초기화하고 있습니다.</p><p>이렇게 되면 이 함수는 이제 크로스 스레드에 안전한 코드가 됩니다.</p><p>그리고 이 함수의 내부는 이렇게 표현될 수 있습니다.</p><p>(* <b>흐름은 위에서 밑으로 가는 순차적인 구조입니다. 탭은 분기를 나타냅니다.</b>)</p><p><br /></p><p>CSafeSetText 메서드 호출</p><p>컨트롤의 InvokeRequired 속성</p><p style="margin-left:2em;">TRUE</p><p style="margin-left:4em;">컨트롤이 스레드를 생성하고, 생성된 스레드에서 CSafeSetText 메서드를 호출</p><p style="margin-left:4em;">CSafeSetText 메서드가 호출되면, 다시 위에서부터 내려오게 되지만 InvokeRequired 속성은 FALSE로 되기 때문에 바로 Text 속성에 접근하게 됨</p><p style="margin-left:2em;">FALSE</p><p style="margin-left:4em;">스레드 생성 없이 바로 Text 속성에 접근하여 텍스트 변경</p><p><br /></p><p><br /></p><p>그리고 최종적인 프로그램의 코드는 이렇습니다.</p><p class="codetext" style="border:1px solid #ababab;"><span style="color:#008000;font-weight:bold;">using</span> System;<br /><span style="color:#008000;font-weight:bold;">using</span> System.Collections.Generic;<br /><span style="color:#008000;font-weight:bold;">using</span> System.Drawing;<br /><span style="color:#008000;font-weight:bold;">using</span> System.Threading;<br /><span style="color:#008000;font-weight:bold;">using</span> System.Windows.Forms;<br /><span style="color:#008000;font-weight:bold;">namespace</span> CrossThreadSafetyAccess {<br />


    <span style="color:#0000ff;font-weight:bold;">public</span> <span style="color:#000080;">partial</span> <span style="color:#ff0000;">class</span> MainForm : Form {<br />


        <span style="color:#0000ff;font-weight:bold;">public</span> <span style="color:#191970;font-weight:bold;">MainForm</span>() {<br />


            <span style="color:#191970;font-weight:bold;">InitializeComponent</span>();<br />


        }<br /><br />


        <span style="color:#ff0000;">delegate</span> <span style="color:#ff0000;">void</span> <span style="color:#191970;font-weight:bold;">CrossThreadSafetySetText</span>(Control ctl, String text);<br />


                <br />


        <span style="color:#0000ff;font-weight:bold;">private</span> <span style="color:#ff0000;">void</span> <span style="color:#191970;font-weight:bold;">CSafeSetText</span>(Control ctl, String text) {<br />


            <br />


            <span style="color:#008000;">/*</span><br /><span style="color:#008000;">             * InvokeRequired 속성 (<a href="http://msdn.microsoft.com/ko-kr/library/system.windows.forms.control.invokerequired(v=vs.110).aspx" target="_blank" class="tx-link" rel="nofollow noreferrer noopener">Control.InvokeRequired</a>, MSDN)</span><br /><span style="color:#008000;">             *   짧게 말해서, 이 컨트롤이 만들어진 스레드와 현재의 스레드가 달라서</span><br /><span style="color:#008000;">             *   컨트롤에서 스레드를 만들어야 하는지를 나타내는 속성입니다.  </span><br /><span style="color:#008000;">             * </span><br /><span style="color:#008000;">             * InvokeRequired 속성의 값이 참이면, 컨트롤에서 스레드를 만들어 텍스트를 변경하고,</span><br /><span style="color:#008000;">             * 그렇지 않은 경우에는 그냥 변경해도 아무 오류가 없기 때문에 텍스트를 변경합니다.</span><br /><span style="color:#008000;">             */</span><br />


            <span style="color:#0000ff;font-weight:bold;">if</span> ( ctl.InvokeRequired )<br />


                ctl.<span style="color:#191970;font-weight:bold;">Invoke</span>(<span style="color:#008b8b;font-weight:bold;">new</span> <span style="color:#191970;font-weight:bold;">CrossThreadSafetySetText</span>(CSafeSetText), ctl, text);<br />


            <span style="color:#0000ff;font-weight:bold;">else</span><br />


                ctl.Text = text;<br />


        }<br />


        <br />


        <span style="color:#0000ff;font-weight:bold;">private</span> <span style="color:#ff0000;">void</span> <span style="color:#191970;font-weight:bold;">Button1Click</span>(<span style="color:#ff0000;">object</span> sender, EventArgs e) {<br />


            <span style="color:#191970;font-weight:bold;">CSafeSetText</span>((Control)sender, <span style="color:#0000ff;">"Cross Thread Safety Code"</span>);<br />


        }<br />


        <br />


        <span style="color:#0000ff;font-weight:bold;">private</span> <span style="color:#ff0000;">void</span> <span style="color:#191970;font-weight:bold;">Button2Click</span>(<span style="color:#ff0000;">object</span> sender, EventArgs e) {<br />


            Thread t = <span style="color:#008b8b;font-weight:bold;">new</span> <span style="color:#191970;font-weight:bold;">Thread</span>(CNotSafetySetText);<br />


            t.<span style="color:#191970;font-weight:bold;">Start</span>();<br />


        }<br />


        <span style="color:#0000ff;font-weight:bold;">private</span> <span style="color:#ff0000;">void</span> <span style="color:#191970;font-weight:bold;">CNotSafetySetText</span>() {<br />


            button2.Text = <span style="color:#0000ff;">"Cross Thread Not Safety Code"</span>;<br />


        }<br />


    }<br />


}</p><p><br /></p><p>button1 클릭시엔 크로스 스레드에 안전한 작업이므로 예외 없이 텍스트 설정이 수행됩니다.</p><p>하지만, button2 클릭시엔 크로스 스레드에 안전하지 않은 작업이므로 예외가 발생합니다.</p><p><br /></p><p>이 글에 대한 예제 코드입니다.</p><p><span class="imageblock" style="height:auto;max-width:100%;"><a href="https://slaner.tistory.com/attachment/cfile26.uf@244A9C375429401F22B3BB.zip" rel="nofollow"><img src="https://t1.daumcdn.net/tistory_admin/assets/blog/6ea9bb49f39cfb223b8b0033d4c71b08af25674c/blogs/image/extension/zip.gif?_version_=6ea9bb49f39cfb223b8b0033d4c71b08af25674c" alt="" style="vertical-align:middle;" /> CrossThreadSafetyAccess.zip</a></span></p><p><br /></p><p>이상으로 간단하게 '크로스 스레드 작업이 잘못되었습니다' 라고 나타나는 예외를 처리하는 방법을 설명드렸습니다.</p><p>텍스트 설정하는 것만이 아니라, 이 예제를 보시고 이해함으로써 이 방법을 응용해서 위치 변경, 배경색 변경 등에도 활용할 수 있음을 아셨으면 합니다!</p><p><br /></p><p>긴 글 읽어주셔서 감사합니다!</p></div></div></div></div></div></div>]]></description>
<dc:creator>하나를하더라도최선을</dc:creator>
<dc:date>2019-09-18T22:52:00+09:00</dc:date>
</item>


<item>
<title>[C#] [펌] 세가지 Timer 와 그 차이점</title>
<link>http://assets.program1472.com/bbs/board.php?bo_table=TB_06&amp;amp;wr_id=3</link>
<description><![CDATA[<div class="document_4037_4 xe_content"><p>출처: <a href="http://blog.daum.net/starkcb/117" target="_blank" rel="nofollow noreferrer noopener">http://blog.daum.net/starkcb/117</a></p>


<p><br /></p>


<div class="cContentBody" style="font-family:'굴림', gulim, verdana, sans-serif;color:rgb(85,85,85);line-height:15.600000381469727px;margin:0px;"><div style="line-height:1.3;"><div class="fr" style="line-height:1.3;"><div class="list-blog border-sub" style="line-height:1.3;"><div class="inbox" style="line-height:1.3;"><div class="tbody m-tcol-c" style="line-height:1.3;"><p style="padding:0px;line-height:1.6;">특정 작업을 주기적으로 실행하기 위해 흔히 <strong>Timer</strong> 객체를 사용합니다</p>


<p style="padding:0px;line-height:1.6;">정해진 시간 간격으로 변수를 업데이트 한다던지, 모니터링 한다던지, 로그를 기록 한다던지, 그 작업 내용은 무궁무긴 하겠죠</p>


<p style="padding:0px;line-height:1.6;">Timer 객체는 이러한 주기적 작업을 아주 쉽게 처리해 주는, 닷넷 프레임워크에서 제공하는 고마운 객체입니다</p>


<p style="padding:0px;line-height:1.6;"><br />그러나 한가지 생각해 볼 문제가 있네요..</p>


<p style="padding:0px;line-height:1.6;">닷넷 프레임워크에는 무려 <font color="#3a32c3"><strong>3가지 서로 다른</strong> <strong>Timer</strong> </font>를 제공하고 있다는 겁니다. 바로 아래 3가지 Timer 입니다<br /><strong>1. System.WIndows.Forms.Timer<br />2. System.Threading.Timer</strong></p>


<p style="padding:0px;line-height:1.6;"><strong>3. System.Timers.Timer</strong></p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"><font color="#ff0000">닷넷이 이 3가지 Timer 를 각각 제공하는 이유가 무엇일까요?</font></p>


<p style="padding:0px;line-height:1.6;">필자는 이 문제(?)에 대해, 몇 년전에 의구심을 가졌읍니다만, 당시 의구심만 가진채 그냥 세월을 보내 버렸습니다 --;</p>


<p style="padding:0px;line-height:1.6;">그리고는 대략 아는 지식으로 대략 <u>적절 할 것 같은</u>(?) Timer을 사용해 왔던 것 같습니다</p>


<p style="padding:0px;line-height:1.6;">게을렀던 거죠. 의구심이 들면 파고들어 정복하는 사람이 성공합니다. ㅋㅋ , 기술이든 인생이든...</p>


<p style="padding:0px;line-height:1.6;">예기가 다른 길로 세네요.. ㅎ,</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">우선 이 세가지 서로다른 Timer 의 msdn 설명을 볼까요</p>


<table border="0" cellspacing="1" cellpadding="0" width="671" bgcolor="#b7bbb5" style="height:40px;color:rgb(51,51,51);line-height:1.3;"><tbody><tr bgcolor="#ffffff"><td width="671" style="color:rgb(85,85,85);line-height:1.3;"><p style="padding:0px;line-height:1.6;"><br /><strong>1) System.Windows.Forms.Timer</strong><br />사용자가 <font color="#0075c8">정의한 간격마다 이벤트를 발생</font>시키는 타이머를 구현합니다. 이 타이머는 <font color="#0075c8">Windows Forms </font>응용 프로그램에서</p>


<p style="padding:0px;line-height:1.6;">사용할 수 있도록 <font color="#0075c8">최적화</font>되었으며 창에서 사용해야 합니다<br /><br /><strong>2) System.Threading.Timer</strong></p>


<p style="padding:0px;line-height:1.6;"><font color="#0075c8">지정된 간격으로 메서드를 실행</font>하는 메커니즘을 제공합니다</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"><strong>3) System.Timers.Timer</strong></p>


<p style="padding:0px;line-height:1.6;">응용 프로그램에 <font color="#0075c8">되풀이 이벤트를 생성</font>합니다</p>


<p style="padding:0px;line-height:1.6;"> </p>


</td></tr></tbody></table><p style="padding:0px;line-height:1.6;"><br />msdn 설명을 봐도,<br />'<em>System.WIndows.Forms.Timer 가 윈도우 응용프로그램에 최적화 되었다</em>' 라는 말 빼고는 거의 차이점을 느낄 수 없네요</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">물론 msdn은 보다 상세한 내용을 더 기술되어 있습니다만, 이 글에서는 이 세가지 Timer 의 차이점을 크게 두 가지 측면에서 <br />살펴 볼까 합니다</p>


<p style="padding:0px;line-height:1.6;"><strong>1. 사용법상의 차이점</strong></p>


<p style="padding:0px;line-height:1.6;"><strong>2. 수행되는 Thread 환경의 차이점</strong></p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"><strong><font color="#009e25"><span style="font-size:11pt;">* 사용법의 차이</span></font></strong></p>


<p style="padding:0px;line-height:1.6;">먼저 사용법의 차이를 알아보죠</p>


<p style="padding:0px;line-height:1.6;">사용법의 차이는 말 그대로 사용법입니다. 이것이 원리는 아니죠.<br />원리가 다르기 때문에 사용법이 다른 것이지, 사용법이 다르기 때문에 원리가 다른건 아닙니다</p>


<p style="padding:0px;line-height:1.6;">그럼에도, 사용법 차이점부터 알아 보는 것은.......... 쉽기 때문이죠 ^^;</p>


<p style="padding:0px;line-height:1.6;">(<font color="#9a9a9a">개발자 여러분, 사용법만 익히지 말고 원리를 익힙시다</font>)</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"><strong>1. System.Windows.Forms.Timer 사용법</strong><br />윈도우 응용프로그램 개발자들에겐 아마 가장 익숙한 Timer 일 것입니다<br /><br /></p>


<p style="padding:0px;line-height:1.6;">- 객체 생성</p>


<p style="padding:0px;line-height:1.6;">System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();<br /><br /></p>


<p style="padding:0px;line-height:1.6;">- 반복 주기 및 작업 설정</p>


<p style="padding:0px;line-height:1.6;">timer.Interval = 1000; //주기 설정</p>


<p style="padding:0px;line-height:1.6;">timer.Tick += new EventHandler(timer_Tick); //주기마다 실행되는 이벤트 등록</p>


<p style="padding:0px;line-height:1.6;">void tmrWindowsFormsTimer_Tick(object sender, System.EventArgs e)<br />{<br />      //수행해야할 작업</p>


<p style="padding:0px;line-height:1.6;">}<br /></p>


<p style="padding:0px;line-height:1.6;">- Timer 시작</p>


<p style="padding:0px;line-height:1.6;">timer.Enable = true 또는 timer.Start();<br /></p>


<p style="padding:0px;line-height:1.6;">- Timer 중지</p>


<p style="padding:0px;line-height:1.6;">timer.Enable = false 또는 timer.Stop();</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"><strong>2. System.Threading.Timer 사용법</strong></p>


<p style="padding:0px;line-height:1.6;">- 객체 생성</p>


<p style="padding:0px;line-height:1.6;">Timer 객체를 생성할 때, 반복적으로 실행하게 될 메서드를 콜백 메서드로 등록해야 합니다</p>


<p style="padding:0px;line-height:1.6;">System.Threading.Timer timer = new System.Threading.Timer(CallBack);<br /><br /></p>


<p style="padding:0px;line-height:1.6;">- 반복 주기 및 작업 설정</p>


<p style="padding:0px;line-height:1.6;">이 Timer 에는 Change 메서드가 있는데, 이 메서드는 dueTime과 period 를 입력받습니다</p>


<p style="padding:0px;line-height:1.6;">dueTime은 Timer 가 시작하기 전 대기(지연)시간이며 period는 반복 주기입니다<br />timer.Change(0, 1000);<br /><br />그리고 반복 실행 작업이,<br />윈도우 응용프로그램의 UI Thread와 연관된다면, Cross Thread 문제가 발생하기 때문에 Invoke나 BeginInvoke를</p>


<p style="padding:0px;line-height:1.6;">통해 핸들링 해야 합니다.</p>


<p style="padding:0px;line-height:1.6;">앞서, Timer 객세 생성시 등록한 콜백 메서드에서 BeginInvoke를 통해 UI 쓰레드를 핸들링 할 수 있습니다</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">delegate void TimerEventFiredDelegate();</p>


<p style="padding:0px;line-height:1.6;">void CallBack(Object state)<br />{<br />    BeginInvoke(new TimerEventFiredDelegate(Work));<br />}<br />        <br />private void Work()<br />{</p>


<p style="padding:0px;line-height:1.6;">     //수행해야할 작업(UI Thread 핸들링 가능)<br />}</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">- Timer 시작</p>


<p style="padding:0px;line-height:1.6;">위의 Change 메서드의 dueTime 이 0 이므로 그 즉시 시작된다. Start와 같은 별도의 시작 명령이 존재하지 않음<br /></p>


<p style="padding:0px;line-height:1.6;">- Timer 중지<br />timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);</p>


<p style="padding:0px;line-height:1.6;">dueTime와 period 를 무한대로 잡아서 Timer 가 실행되지 않도록 하는 것이 중지하는 것과 같습니다</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"><strong>3. System.Timers.Timer 사용법</strong></p>


<p style="padding:0px;line-height:1.6;">- 객체 생성</p>


<p style="padding:0px;line-height:1.6;">System.Timers.Timer timer = new System.Timers.Timer();</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">- 반복 주기 및 작업 설정<br />timer.Interval = 1000;<br />timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);  //주기마다 실행되는 이벤트 등록</p>


<p style="padding:0px;line-height:1.6;"><br />이 Timer 역시 UI Thread를 핸들링 하기 위해서 Invoke 나 BeginInvoke를 이용해야 합니다<br />delegate void TimerEventFiredDelegate();<br />void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)<br />{<br />    BeginInvoke(new TimerEventFiredDelegate(Work));            <br />}</p>


<p style="padding:0px;line-height:1.6;">private void Work()<br />{</p>


<p style="padding:0px;line-height:1.6;">     //수행해야할 작업(UI Thread 핸들링 가능)<br />}</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">- Timer 시작</p>


<p style="padding:0px;line-height:1.6;">timer.Enable = true 또는 timer.Start();<br /></p>


<p style="padding:0px;line-height:1.6;">- Timer 중지</p>


<p style="padding:0px;line-height:1.6;">timer.Enable = false 또는 timer.Stop();</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">결론적으로 보면,</p>


<p style="padding:0px;line-height:1.6;">Timer 객체의 사용법 자체는 그리 어렵지 않습니다. 또한 세 가지 Timer 의 사용법은 대동소이 함을 알 수 있습니다</p>


<p style="padding:0px;line-height:1.6;">다만 윈도위 응용프로그램에서 Timer 를 사용할 때 System.WIndows.Forms.Timer 를 제외하고는</p>


<p style="padding:0px;line-height:1.6;">UI Thread 에서 만들어진 컨트롤에 접근하려면 크로스 쓰레드 문제가 있으므로 마샬링 된 호출(Invoke / BeginInvoke) 를</p>


<p style="padding:0px;line-height:1.6;">이용해야 하는 차이점이 있습니다</p>


<p style="padding:0px;line-height:1.6;">msdn의 설명처럼 System.Windows.Forms.Timer 는 윈도우 응용프로그램에 최적화 되어 있나 보네요..</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">그럼 왜 System.Windows.Forms.Timer 는 크로스쓰레드 문제가 발생하지 않을까요?</p>


<p style="padding:0px;line-height:1.6;">그리고 정말 사용법 처럼 크게 차이가 나지 않는 걸까요?</p>


<p style="padding:0px;line-height:1.6;"><br />다음에 설명할, 두번째 관점인 '수행되는 Thread 환경의 차이점'에서 이를 알아보도록 하죠</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"><strong><span style="font-size:12pt;"><font color="#009e25"><span style="font-size:11pt;">* 수행되는 쓰레드(Thread) 환경의 차이</span></font></span></strong></p>


<p style="padding:0px;line-height:1.6;">앞서 사용법에서 UI Thread 라는 말을 했습니다</p>


<p style="padding:0px;line-height:1.6;">윈도우 응용프로그램을 예로 들어, 버턴이나 각종 컨트롤이 생성되고 핸들링 되는 것은 UI Thread 상에서 이루어집니다</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">이와 다른 개념이 Work Thread 인데요, 기본 쓰레드(Default Thread) 이외에 <br />개발자가 별도의 쓰레드를 생성하여 작업을 실행한다면 이는 Work Thread(작업자 쓰레드) 라 합니다</p>


<p style="padding:0px;line-height:1.6;">또한 UI Thread 입장에서는, 닷넷의 ThreadPool 에 의해 실행되는 쓰레드도 Work Thread 로 볼 수 있습니다</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">쓰레드가 다르다면 쓰레드의 고유번호도 당연히 다릅니다</p>


<p style="padding:0px;line-height:1.6;"><font color="#0075c8">System.Threading.Thread.CurrentThread.IsThreadPoolThread 속성은 현재 쓰레드의 고유 식별자 값을 가져 옵니다</font></p>


<p style="padding:0px;line-height:1.6;">우린 이 속성을 통해 Timer 객체가 수행되는 쓰레드를 알아 보도록 하겠습니다</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"><strong>1. System.Windows.Forms.Timer 의 쓰레드 환경</strong></p>


<p style="padding:0px;line-height:1.6;">윈도우 응용프로그램에 최적회 되어 있다는 이 Timer 는 윈도우 응용프로그램 기본 쓰레드와 동일한 쓰레드 상에서 동작합니다</p>


<p style="padding:0px;line-height:1.6;">이를 확인하기 위해, 다음과 같이 코드 중간에 IsThreadPoolThread  속성을 확인해 봅니다</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">- 기본 쓰레드의 고유 번호를 확인한다</p>


<p style="padding:0px;line-height:1.6;">윈도우응용프로그램 생성자나 기타 이벤트에서 아래 코드를 기입합니다</p>


<p style="padding:0px;line-height:1.6;"><font color="#009e25">MessageBox.Show(System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());</font></p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">- Timer 쓰레드의 고유번호를 확인한다</p>


<p style="padding:0px;line-height:1.6;">Timer 의 Tick 이벤트에서 다음의 코드를 기입합니다</p>


<p style="padding:0px;line-height:1.6;">void timer1_Tick(object sender, EventArgs e)<br />{<br />     <font color="#009e25">MessageBox.Show(System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());</font></p>


<p style="padding:0px;line-height:1.6;">     //수행해야할 작업<br />}</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">이렇게 확인 해 보면 두 쓰레드는 동일한 고유번호를 반환하게 됩니다</p>


<p style="padding:0px;line-height:1.6;">이 말은 곧, 윈도우응용프로가램의 기본 쓰레드인 UI Thread 상에서 Timer이 동작한다는 것을 짐작할 수 있습니다</p>


<p style="padding:0px;line-height:1.6;">즉 멀티 쓰레드 환경이 아닌 것이죠</p>


<p style="padding:0px;line-height:1.6;">예로, Tick 이벤트에 시간이 긴~ 작업이 수행된다면 프로그램은 그 시간 동안 블럭 된 대기 한다는 것입니다</p>


<p style="padding:0px;line-height:1.6;"><font color="#ff0000">Timer 의 동작이 기본 프로그램 동작과 독립적으로 수행된다고 생각하시면 안됩니다</font></p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"><strong>2. System.Threading.Timer 의 쓰레드 환경</strong></p>


<p style="padding:0px;line-height:1.6;">역시 앞서와 같이 기본 쓰레드와 Timer 쓰레드의 고유번호를 확인 해 봅니다</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">- 기본 쓰레드의 고유 번호를 확인한다</p>


<p style="padding:0px;line-height:1.6;">윈도우응용프로그램 생성자나 기타 이벤트에서 아래 코드를 기입합니다</p>


<p style="padding:0px;line-height:1.6;"><font color="#009e25">MessageBox.Show(System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());</font></p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">- Timer 쓰레드의 고유번호를 확인한다</p>


<p style="padding:0px;line-height:1.6;">CallBack 메서드에서 다음과 같이 코드를 기입합니다</p>


<p style="padding:0px;line-height:1.6;">void CallBack(Object state)<br />{<br />      <font color="#009e25">MessageBox.Show(System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());</font></p>


<p style="padding:0px;line-height:1.6;">      BeginInvoke(new TimerEventFiredDelegate(Work));<br /> }</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">어떻습니까? 두 쓰레드는 다른 고유번호를 반환하지요</p>


<p style="padding:0px;line-height:1.6;">즉 UI Thread 와 다른 쓰레드, 즉 Work Thread(작업자 쓰레드)임을 알 수 있습니다</p>


<p style="padding:0px;line-height:1.6;">이는 곧 멀티 쓰레드가 된 셈이죠. 두 쓰레드는 서로 독립적으로 수행될 것입니다</p>


<p style="padding:0px;line-height:1.6;">앞서, System.Windows.Forms.Timer 객체와는 달리 CallBack 메서드에 시간이 오래 걸리는 작업을 수행해도</p>


<p style="padding:0px;line-height:1.6;">프로그램이 대기상태로 빠지는 않죠. Timer 동작이 기본 프로그램의 동작과는 독립적으로 수행되는 것이죠.</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">참고로 이 Timer 는 닷넷의 ThreadPool(쓰레드풀) 에서 관리합니다</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"><strong>3. System.Timers.Timer 의 쓰레드 환경</strong></p>


<p style="padding:0px;line-height:1.6;">결론부터 말하자만, 이 Timer 는 기본 쓰레드에서 수행될 수도 있고, 작업자 쓰레드에서 수행될 수도 있습니다</p>


<p style="padding:0px;line-height:1.6;">만일, SynchronizingObject 속성을 폼객체로 한다면 Timer는 UI 쓰레드 상에서 동작할 것이며</p>


<p style="padding:0px;line-height:1.6;">이 속성을 지정하지 않는다면, 작업자 쓰레드 상에서 동작하게 됩니다</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">아래와 같이 SynchronizingObject 속성의 설정 여부에 따른 ManagedThreadid 값을 확인해 보기 바랍니다</p>


<p style="padding:0px;line-height:1.6;"><font color="#009e25">tim</font><font color="#009e25">er.SynchronizingObject = this;</font></p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">타이머 쓰레드의 고유번호를 알기 위해 Elapsed 이벤트에</p>


<p style="padding:0px;line-height:1.6;"><font color="#009e25">MessageBox.Show(System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());</font></p>


<p style="padding:0px;line-height:1.6;">를 확인해 보세요</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">---</p>


<p style="padding:0px;line-height:1.6;">결국 Timer 의 실행이 기본 쓰레드에서 하느냐, 작업자 쓰레드 에서 하느냐에 차이인데요,</p>


<p style="padding:0px;line-height:1.6;">앞서, 사용법의 차이를 살펴 봤을 때 System.Windows.Forms.Timer 객체를 제외하고는 윈도우응용프로그램의 UI 컨트롤</p>


<p style="padding:0px;line-height:1.6;">핸들링 시 크로스 도메인 문제가 발생했던 원인이 되는 것입니다</p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"><strong>* 기타 차이점 및 요약, 참조</strong></p>


<p style="padding:0px;line-height:1.6;">아래 표는 msdn magazine에 소개된 세 Timer 의 차이점에 대한 표입니다</p>


<p style="padding:0px;line-height:1.6;">우리가 알아 본 내용 이외에도, 쓰레드 안정성(동기화 문제)에 대한 내용도 있습니다</p>


<p style="padding:0px;line-height:1.6;"> </p>


<table border="1" cellspacing="0" cellpadding="0" width="100%" style="color:rgb(51,51,51);line-height:1.3;border:medium none;width:768px;border-collapse:collapse;"><tbody><tr><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border:1pt solid #C0C0C0;padding:2.25pt;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><b><span style="font-family:Verdana;color:#000000;font-size:8pt;">&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;</span></b></p><p><b> </b></p><b></b>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:#C0C0C0 #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-top-width:1pt;border-top-style:solid;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><b><span style="font-family:Verdana;color:#000000;font-size:8pt;">System.Windows.Forms</span></b></p><p><b></b></p><b></b>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:#C0C0C0 #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-top-width:1pt;border-top-style:solid;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><b><span style="font-family:Verdana;color:#000000;font-size:8pt;">System.Timers</span></b></p><p><b></b></p><b></b>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:#C0C0C0 #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-top-width:1pt;border-top-style:solid;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><b><span style="font-family:Verdana;color:#000000;font-size:8pt;">System.Threading</span></b></p><p><b></b></p><b></b>


</td></tr><tr><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0;border-bottom-width:1pt;border-bottom-style:solid;border-left-width:1pt;border-left-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;"><strong>Timer event runs on what thread?</strong></span></p><p><strong></strong></p><strong></strong>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">UI thread</span></p><p></p>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">UI or worker thread</span></p><p></p>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">Worker thread</span></p><p></p>


</td></tr><tr><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0;border-bottom-width:1pt;border-bottom-style:solid;border-left-width:1pt;border-left-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;"><strong>Instances are thread safe?</strong></span></p><p><strong></strong></p><strong></strong>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">No</span></p><p></p>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">Yes</span></p><p></p>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">No</span></p><p></p>


</td></tr><tr><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0;border-bottom-width:1pt;border-bottom-style:solid;border-left-width:1pt;border-left-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;"><strong>Familiar/intuitive object model?</strong></span></p><p><strong></strong></p><strong></strong>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">Yes</span></p><p></p>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">Yes</span></p><p></p>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">No</span></p><p></p>


</td></tr><tr><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0;border-bottom-width:1pt;border-bottom-style:solid;border-left-width:1pt;border-left-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;"><strong>Requires Windows Forms?</strong></span></p><p><strong></strong></p><strong></strong>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">Yes</span></p><p></p>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">No</span></p><p></p>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">No</span></p><p></p>


</td></tr><tr><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0;border-bottom-width:1pt;border-bottom-style:solid;border-left-width:1pt;border-left-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;"><strong>Metronome-quality beat?</strong></span></p><p><strong></strong></p><strong></strong>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">No</span></p><p></p>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">Yes*</span></p><p></p>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">Yes*</span></p><p></p>


</td></tr><tr><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0;border-bottom-width:1pt;border-bottom-style:solid;border-left-width:1pt;border-left-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;"><strong>Timer event supports state object?</strong></span></p><p><strong></strong></p><strong></strong>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">No</span></p><p></p>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">No</span></p><p></p>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">Yes</span></p><p></p>


</td></tr><tr><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0;border-bottom-width:1pt;border-bottom-style:solid;border-left-width:1pt;border-left-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;"><strong>Initial timer event can be scheduled?</strong></span></p><p><strong></strong></p><strong></strong>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">No</span></p><p></p>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">No</span></p><p></p>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">Yes</span></p><p></p>


</td></tr><tr><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0;border-bottom-width:1pt;border-bottom-style:solid;border-left-width:1pt;border-left-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;"><strong>Class supports inheritance?</strong></span></p><p><strong></strong></p><strong></strong>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">Yes</span></p><p></p>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">Yes</span></p><p></p>


</td><td valign="top" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0 rgb(236,233,216);border-bottom-width:1pt;border-bottom-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">No</span></p><p></p>


</td></tr><tr><td valign="top" colspan="4" style="color:rgb(85,85,85);line-height:1.3;border-color:rgb(236,233,216) #C0C0C0 #C0C0C0;border-bottom-width:1pt;border-bottom-style:solid;border-left-width:1pt;border-left-style:solid;padding:2.25pt;border-right-width:1pt;border-right-style:solid;"><p align="left" style="margin:0cm 0cm 0pt;padding:0px;line-height:1.6;"><span style="font-family:Verdana;color:#000000;font-size:8pt;">* Depending on the availability of system resources (for example, worker threads)</span></p><p></p>


</td></tr></tbody></table><p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;"> </p>


<p style="padding:0px;line-height:1.6;">마지막으로 msdn의 설명을 옮기며 마칩니다<br /></p>


<div class="seeAlsoNoToggleSection" style="line-height:1.3;"><p style="padding:0px;line-height:1.6;"><a target="_blank" rel="noreferrer noopener"></a></p>


<table border="0" cellspacing="1" cellpadding="0" width="691" bgcolor="#b7bbb5" style="height:432px;color:rgb(51,51,51);line-height:1.3;width:691px;"><tbody><tr bgcolor="#ebebeb"><td width="671" style="color:rgb(85,85,85);line-height:1.3;"> <h1 class="heading" style="font-size:12px;"><span style="font-size:12pt;">서버 타이머, Windows 타이머 및 스레드 타이머</span></h1><div class="seeAlsoNoToggleSection" style="line-height:1.3;"><p style="padding:0px;line-height:1.6;">Visual Studio 및 .NET Framework에는 <font color="#3a32c3">세 개의 타이머 </font>컨트롤 즉, <b>도구 상자</b>의 <b>구성 요소</b> 탭에서 볼 수 있는 서버 기반 타이머, <b>도구 상자</b>의 <b>Windows Forms</b> 탭에서 볼 수 있는 표준 Windows 기반 타이머 및 프로그래밍 방식으로만 사용할 수 있는 스레드 타이머가 있습니다. <br /><br /><strong>Windows 기반 타이머</strong>는 Visual Basic 1.0 이상의 버전에 있으며 지금까지 크게 변경되지 않았습니다. <br /><font color="#3a32c3">이 타이머는 Windows Forms 응용 프로그램에서 사용하도록 최적화되어 있습니다</font>. <br />서버 기반 타이머는 <font color="#3a32c3">일반 타이머를 서버 환경에서 최적으로 실행되도록 업데이트한 것</font>입니다. <br /><br /><strong>스레드 타이머</strong>는 이벤트 대신 콜백 메서드를 사용하는 <font color="#3a32c3">간단한 소형 타이머로서 스레드 풀 스레드에서 제공</font>합니다.<br /></p>


<p style="padding:0px;line-height:1.6;">Win32 아키텍처에는 UI 스레드와 작업자 스레드라는 두 종류의 스레드가 있습니다. <br />UI 스레드는 대부분의 시간을 유휴 상태로 보내며 메시지 루프에 메시지가 도착할 때까지 기다립니다. 메시지가 도착하면 <br />이 메시지를 처리하고 다음 메시지가 도착할 때까지 기다립니다. 이에 비해 작업자 스레드는 백그라운드 처리를 수행하는 데 사용하며 메시지 루프를 사용하지 않습니다. <br /><br />Windows 타이머와 서버 기반 타이머는 모두 <code>Interval</code> 속성을 사용하여 실행됩니다. <br />스레드 타이머의 간격은 &lt;?XML:NAMESPACE PREFIX = MSHelp NS = "<a href="http://msdn.microsoft.com/mshelp" target="_blank" rel="nofollow noreferrer noopener">http://msdn.microsoft.com/mshelp"</a> /&gt;Timer 생성자에서 설정됩니다. <br />스레드에서 타이머를 다루는 방식을 보면 알 수 있듯이 <strong>각 타이머의 용도는 서로 다릅니다</strong>.</p>


<ul><li style="line-height:1.3;"><p style="padding:0px;line-height:1.6;"><strong>Windows 타이머</strong>는 UI 스레드가 프로세싱을 수행하는 데 사용하는 <a target="_blank" rel="noreferrer noopener"></a><font color="#3a32c3">단일 스레드 환경을 위해 설계</font>되었습니다. Windows 타이머의 <font color="#3a32c3">정확도는 55밀리초로 제한</font>되어 있습니다. 이 일반 타이머는 사용자 코드에서 사용할 수 있는 <br />UI 메시지 펌프가 필요하며 항상 동일한 스레드에서 실행되거나 다른 스레드로 마샬링됩니다. <br />이 기능은 COM 구성 요소의 성능을 저하시킵니다. <br /></p>


</li><li style="line-height:1.3;"><p style="padding:0px;line-height:1.6;"><strong>서버 기반 타이머</strong>는 <font color="#3a32c3">다중 스레드 환경에서 작업자 스레드와 함께 사용하도록 설계</font>되었습니다. 두 스레드는 서로 다른 아키텍처를 사용하므로 <font color="#3a32c3">서버 기반 타이머가 Windows 타이머보다 정확</font>합니다. <br />서버 타이머는 스레드 사이를 이동하면서 발생한 이벤트를 처리할 수 있습니다. <br /></p>


</li><li style="line-height:1.3;"><p style="padding:0px;line-height:1.6;"><strong>스레드 타이머</strong>는 메시지가 스레드에서 펌프되지 않는 경우에 유용합니다. <br />예를 들어, Windows 기반 타이머는 운영 체제의 타이머 지원 기능에 의존하며 스레드에서 메시지를 펌프하지 않을 경우에는 타이머 관련 이벤트가 발생하지 않습니다. 이 경우에는 스레드 타이머가 보다 더 유용합니다.</p>


</li></ul><p style="padding:0px;line-height:1.6;">Windows 타이머는 System.Windows.Forms 네임스페이스에, 서버 타이머는 System.Timers 네임스페이스에 그리고 스레드 타이머는 System.Threading 네임스페이스에 있습니다.</p>


</div></td></tr></tbody></table></div></div></div></div></div></div></div><div class="article_to_sns_wrap" style="font-family:'굴림', gulim, verdana, sans-serif;color:rgb(76,76,76);line-height:15.600000381469727px;height:95px;clear:both;margin:25px auto 0px;padding:0px;text-align:center;"><div class="article_to_sns_box" style="color:rgb(85,85,85);line-height:1.3;width:266px;height:24px;padding:0px;margin:0px;"></div></div><p><br /></p>


<p><br /></p>


<p><br /></p>


<p><br /></p>


<p><br /></p></div>]]></description>
<dc:creator>하나를하더라도최선을</dc:creator>
<dc:date>2019-09-18T19:06:35+09:00</dc:date>
</item>


<item>
<title>[한글 ActiveX C#] 한글문서로 부터 Text, Html추출</title>
<link>http://assets.program1472.com/bbs/board.php?bo_table=TB_06&amp;amp;wr_id=2</link>
<description><![CDATA[<div class="titleWrap">


						<h2><a href="/187">[한글 ActiveX C#] 한글문서로 부터 Text, Html추출</a></h2>


						<span class="category"><a href="/category/%EB%B0%9C%EC%9E%90%20%EC%9D%B4%EC%95%BC%EA%B8%B0/%ED%95%9C%EA%B8%80%28HNC%29%20%EC%BB%A8%ED%8A%B8%EB%A1%A4%20%EC%82%AC%EC%9A%A9">발자 이야기/한글(HNC) 컨트롤 사용</a> </span>


						<span class="date">2009.09.25 11:26</span>


						


					</div>


					


					<div class="article">


						<p><br />


string filePath = @"c:\sample.hwp"   //샘플 한글파일의 경로<br />


HwpCtrl1.Open(filePath);<br /><br />textBox.text = HwpCtrl1.GetTextFile("TEXT","").ToString();   <br />


// 작업환경은 윈폼이고, 폼에 textBox가 올려져 있다고 가정한 코드이다.<br />


// 한글 파일로부터 TEXT 추출시 HTML로 추출을 원하면 해당 값을 HTML로 입력하면 된다.<br /><br />참 쉽죠잉~~~!!<br /><br /><br /><br />삽질하다 알게된 다른 방법이 있다.<br /><br />string filePath = @"c:\sample.hwp"   //샘플 한글파일의 경로<br />


HwpCtrl1.Open(filePath);<br /><br />// 여기까지는 동일하다.<br /><br />HwpCtrl1.InitScan();   // 문서 검색을 위한 초기화<br />


while(<strong>GetText()</strong> != 1)<br />


{<br />


}<br />


HwpCtrl1.ReleaseScan();   //<span lang="en-us" xml:lang="en-us">InitScan()으로 설정된 정보를 초기화 한다.<br /><br /><br />


private int GetText()<br />


        {<br />


            int ret = 0;</span></p>


<p><span lang="en-us" xml:lang="en-us">            HWPCONTROLLib.HwpParameterSet TextSet; <br />


            TextSet = (HWPCONTROLLib.HwpParameterSet)HwpCtrl1.CreateSet("GetText");<br />


            ret = HwpCtrl1.GetTextBySet(TextSet);<br />


            var txt = TextSet.Item("Text");<br />


            <br />


            textBox1.Text += txt;<br />


            return ret;<br />


        }</span></p>    


					</div>]]></description>
<dc:creator>하나를하더라도최선을</dc:creator>
<dc:date>2019-08-03T00:04:39+09:00</dc:date>
</item>


<item>
<title>[한글 ActiveX C#] HwpCtrl 보안승인모듈</title>
<link>http://assets.program1472.com/bbs/board.php?bo_table=TB_06&amp;amp;wr_id=1</link>
<description><![CDATA[<p class="HStyle0" style="margin-top:0px;margin-bottom:0px;line-height:150%;"><span style="font-family:'굴림';">한글 ActiveX 컨트롤을 사용하여 문서를 열 때 "<strong>접근을 허용하시겠습니까?" </strong>라는 내용의 대화상자를 볼수 있다. 물론 이는 보안상 중요하나, 매 사용시 불편한 점이 많다. <br /><br /><a title="[http://www.haansoft.com/hnc/swlab/tech/down_read.action]로 이동합니다." href="http://www.haansoft.com/hnc/swlab/tech/down_read.action" target="_blank" rel="nofollow noreferrer noopener">이를 해결하는 방법으로 한글과 컴퓨터 홈페이지에 해결 방법들이 제시되어 있지만 C++, VB, HTML 로만 안내가 되어 있어서 따로 글을 남겨본다.</a>


<br /><br /></span></p>


<p class="HStyle0" style="margin-top:0px;margin-bottom:0px;line-height:150%;">위의 링크로 가서 DLL을 다운로드 받는다.<br />


해당 프로젝트의 bin\debug 폴더에 복사한다.(DLL의 이름은 바꿔줘도 상관 없다.)<br /><br />샘플코드<br /></p>


<div class="txc-textbox" style="border-right:#f3c534 1px dashed;padding-right:10px;border-top:#f3c534 1px dashed;padding-left:10px;padding-bottom:10px;border-left:#f3c534 1px dashed;padding-top:10px;border-bottom:#f3c534 1px dashed;background-color:#fefeb8;">const string HNCRoot = @"HKEY_Current_User\Software\HNC\HwpCtrl\Modules";<br />


axHwpCtrl1.Clear();<br />


string myProjectPath= Path.GetFullPath(".\\");<br />


if (Microsoft.Win32.Registry.GetValue(HNCRoot, "FilePathCheckerModuleExample", "Not Exist").Equals("Not Exist"))<br />


{<br />


Microsoft.Win32.Registry.SetValue(HNCRoot, "FilePathCheckerModuleExample", projectPath + "FilePathCheckerModuleExample.dll");<br />


}<br />


axHwpCtrl1.RegisterModule("FilePathCheckDLL", "FilePathCheckerModuleExample"); 


<p class="HStyle0" style="margin-top:0px;margin-bottom:0px;line-height:150%;"><br />


string filePath = "파일명.hwp";<br />


axHwpCtrl1.Open(filePath);</p><br /></div>]]></description>
<dc:creator>하나를하더라도최선을</dc:creator>
<dc:date>2019-08-03T00:02:54+09:00</dc:date>
</item>

</channel>
</rss>
