<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[OldbeeDev - Medium]]></title>
        <description><![CDATA[꿀벌 노동자의 얕고 좁은 코딩 아티클 - Medium]]></description>
        <link>https://medium.com/oldbeedev?source=rss----2cdc9c37f155---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>OldbeeDev - Medium</title>
            <link>https://medium.com/oldbeedev?source=rss----2cdc9c37f155---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 14:35:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/oldbeedev" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[[MariaDB] Setting utf8mb4 Character Set]]></title>
            <link>https://medium.com/oldbeedev/mysql-utf8mb4-character-set-%EC%84%A4%EC%A0%95%ED%95%98%EA%B8%B0-da7624958624?source=rss----2cdc9c37f155---4</link>
            <guid isPermaLink="false">https://medium.com/p/da7624958624</guid>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[utf-8]]></category>
            <dc:creator><![CDATA[김정환(John.Kim)]]></dc:creator>
            <pubDate>Thu, 05 Mar 2020 08:03:32 GMT</pubDate>
            <atom:updated>2020-03-06T09:19:31.486Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5wWvIDF3MAJdPYEUI3InuA.png" /><figcaption>Image by <a href="https://pixabay.com/users/Pixaline-1569622/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=2762568">Pixaline</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=2762568">Pixabay</a></figcaption></figure><h4>utf8mb4 등장</h4><p>UTF-8 인코딩은 4바이트 가변 길이 인코딩 방식입니다. 그런데 MySQL에서는 utf8을 3바이트로 구현했었습니다. 그러다가 MySQL 5.5.3 (2010년 3월 24일)에 4바이트짜리 character set인 <strong>utf8mb4</strong>을 추가했습니다.</p><p>유니코드 U+10000 이상인 문자들을 UTF-8로 인코딩하려면 4바이트가 필요한데 이에 해당하는 대표적인 문자들은 다음과 같은 Emoji 입니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h8Q-F7EU-pxv29p_n5d0EA.png" /><figcaption>출처 : <a href="http://www.isthisthingon.org/unicode/allchars1.php">http://www.isthisthingon.org/unicode/allchars1.php</a></figcaption></figure><h3>utf8mb4 설정하기</h3><p>MySQL 및 MariaDB에서 utf8mb4를 사용하려면 my.cnf (리눅스) 나 my.ini (윈도우즈) 설정 파일을 다음과 같이 수정합니다.</p><pre>[mysqld]<br>character-set-server=utf8mb4<br>collation-server=utf8mb4_unicode_ci<br>skip-character-set-client-handshake</pre><p>위의 설정은 <strong>MySQL 5.5, MariaDB 5.5 이후 버전</strong>에서 사용할 수 있습니다. 이제 DB 서버를 재시작하고 mysql 클라이언트에서 아래의 명령으로 상태를 확인해봅니다.</p><pre>show variables like &#39;c%&#39;;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*ew26aFe3pu37sVunCIqmAQ.png" /></figure><h4>character_set_server</h4><p>DB 서버의 기본 문자셋으로서 설정 파일에 명시한 대로 utf8mb4 로 설정되어 있습니다.</p><h4>character_set_database</h4><p>이 변수 값은 현재 사용 중인 database에 따라 다르게 표시될 수 있습니다. database=none인 상태에서는 서버 기본 문자셋인 utf8mb4로 보이지만, 문자셋이 latin1인 database 안에 들어가면 character_set_database=latin1 이라고 나옵니다.</p><h4>character_set_client, character_set_connection, character_set_results</h4><p>클라이언트가 DB 서버와 connection을 맺을 때 handshake 과정이 진행됩니다. 이때 클라이언트는 자신이 사용할 문자셋을 알려줍니다. 서버에서는 이 값으로 character_set_client, character_set_connection, character_set_results를 설정합니다.</p><p>그러나 설정 파일에서 skip-character-set-client-handshake 옵션을 사용하면 클라이언트에서 알려준 문자셋을 무시하고 character_set_server 값으로 이 세 변수 값이 설정됩니다.</p><h4>collation_server</h4><p>설정 파일에 따라 utf8mb4_unicode_ci로 설정되어 있습니다. collation은 문자열 정렬 규칙입니다. 자세한 설명은 <a href="https://blog.lael.be/post/917">라엘님 블로그</a>를 참고 바랍니다.</p><h4>collation_database</h4><p>이 변수 값은 현재 사용 중인 database에 따라 다르게 표시될 수 있습니다. database=none인 상태에서는 collation_server 값이 표시되지만 문자셋이 latin1인 database 안에 들어가면 collation_database=latin1_swedish_ci 라고 나옵니다.</p><h4>collation_connection</h4><p>명시적인 설정이 없다면 character_set_connection 설정에 따라 기본 collation이 선택됩니다. 예를 들어 latin1이면 latin1_swedish_ci, utf8mb4이면 utf8mb4_general_ci가 기본 collation입니다.</p><p>여기서는 skip-character-set-client-handshake 옵션에 따라 collation_server가 대신 사용되어 utf8mb4_unicode_ci가 표시됩니다.</p><h3>옵션 변경 시도</h3><p>위의 옵션을 조금 변경해 보면 결과가 어떻게 달라지는지 알아보았습니다.</p><h4>skip-character-set-client-handshake 옵션</h4><p>만약 이 옵션을 사용하지 않으면 어떨게 될까요?</p><pre>[mysqld]<br>character-set-server=utf8mb4<br>collation-server=utf8mb4_unicode_ci</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*TEYbqaGOIin3cv6yCQU3UQ.png" /></figure><p>위의 그림과 같이 character_set_client, character_set_connection, character_set_results에는 클라이언트 측 문자셋이 euckr이 적용되고, collation_connection 역시 euckr_korean_ci로 설정된 것을 확인할 수 있습니다.</p><h4>init-connect 옵션</h4><p>QnA 검색을 하다보면 아래와 같이 설정하면 된다는 내용도 나옵니다.</p><pre>[mysqld]<br>character-set-server=utf8mb4<br>collation-server=utf8mb4_unicode_ci<br><strong>init-connect=SET NAMES &#39;utf8mb4&#39; COLLATE &#39;utf8mb4_unicode_ci&#39;</strong></pre><p>init-connect 옵션은 DB 서버의 init-connect 변수에 저장되는 값입니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*7SohMihMbU2PcnYnLrSXMQ.png" /></figure><p>DB 서버는 클라이언트와 connection이 맺어지면 init-connect 변수에 있는 명령어 스크립트를 자동으로 수행합니다.</p><p>SET NAMES는 character_set_client, character_set_connection, character_set_results, collation_connection 을 한번에 설정하는 명령어입니다.</p><p>수행 결과는 아래와 같습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*ew26aFe3pu37sVunCIqmAQ.png" /></figure><p>잘 됩니다!</p><p>그런데 한가지 문제가 있는데, init-connect 옵션은 DB 접속 계정의 권한이 SUPER privilege 일 때, 즉 root 유저일 때는 수행되지 않는다는 점입니다.</p><p>이는 DB 복구 시나리오 때문입니다. MySQL은 init-connect 에 명시된 명령어에 syntax error가 있으면 클라이언트와의 연결을 끊어버린다고 합니다. 그런데 만약 root 유저마저도 이런 이유로 접속이 막힌다면 DB를 복구할 방법이 없어져 버리는 겁니다.</p><p>mysql 클라이언트에서 root 계정으로 DB에 로그인해보면 다음과 같이 euckr이 보입니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*TEYbqaGOIin3cv6yCQU3UQ.png" /></figure><p>따라서 init-connnect 옵션은 사용자를 햇갈리게 할 수 도 있으니 안 쓰는게 좋겠다는 생각이 듭니다.</p><p>그러나 다른 한 편으로는 평상시에 root 권한으로 DB에 접속하는 것은 권장할 것이 아니기 때문에, 위와 같은 불일치 정도는 개발이나 서비스 운용시 큰 문제가 아니다라는 생각도 듭니다.</p><p>꼭 필요하면 root 로 로그인한 다음에 SET NAMES utf8mb4; 명령어 한 번만 치면 되니까요.</p><h4>init-connect 옵션을 2개?</h4><p>가끔 init-connect 옵션을 2개 이상 쓰신 분도 봤습니다.</p><pre>[mysqld]<br>character-set-server=utf8mb4<br>collation-server=utf8mb4_unicode_ci<br><strong>init-connect=SET NAMES &#39;utf8mb4&#39;<br>init-connect=SET collation_connection=&#39;utf8mb4_unicode_ci&#39;</strong></pre><p>이렇게 하면 둘 다 적용되는게 아니라, 마지막 명령어만 서버의 init-connect 변수에 저장됩니다. 만약 2개 이상의 명령어를 수행하고 싶으면 세미콜론 (;)을 구분자로 하여 명령어를 이어 적으면 됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*LW-D0Dk9o4Tc_7uZCowQbg.png" /></figure><p>수행 결과는 아래와 같습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*qXUYhRVcY9gBDe0tbglaLA.png" /><figcaption>일반 권한으로 접속</figcaption></figure><p>character_set_client, character_set_results는 euckr로 설정되고, collation_connection=utf8mb4_unicode_ci가 되면서 이에 대응하는 character_set_connection도 utf8mb4로 설정되었습니다.</p><p>아마도 이 설정을 했던 분이 원하던 결과는 아니었을 것입니다.</p><h3>Client Library로 접속시 차이점</h3><p>MariaDB 접속을 위한 C# library로 <a href="https://mysqlconnector.net/">MySqlConnector</a> 를 사용하고 있습니다. 지금까지는 mysql 클라이언트로만 character set 설정 상태를 확인했는데요, 제가 짠 프로그램과 DB 세션 간에는 어떻게 설정되는지 궁금해졌습니다.</p><p>my.ini 설정은 아래와 같습니다.</p><pre>[mysqld]<br>character-set-server=utf8mb4<br>collation-server=utf8mb4_unicode_ci<br>skip-character-set-client-handshake</pre><p>테스트 프로그램은 아래처럼 간단합니다.</p><pre>private static void TestConnection()<br>{<br>    var builder = new MySqlConnectionStringBuilder<br>    {<br>        Server = DbServer,<br>        Port = 3306,<br>        Database = MainDbName,<br>        UserID = Uid,<br>        Password = Pwd<br>    };</pre><pre>    using (var conn = new MySqlConnection(builder.ConnectionString))<br>    {<br>        var result = conn.Query(&quot;SHOW VARIABLES LIKE &#39;c%&#39;&quot;);<br>        foreach (var row in result)<br>        {<br>            Debug.WriteLine($&quot;{row.Variable_name}, {row.Value}&quot;);<br>        }<br>    }<br>}</pre><p>결과는 이랬습니다.</p><pre>character_set_client, utf8mb4<br>character_set_connection, utf8mb4<br>character_set_database, utf8mb4<br>character_set_filesystem, binary<br>character_set_results, utf8mb4<br>character_set_server, utf8mb4<br>character_set_system, utf8<br>character_sets_dir, C:\Program Files\MariaDB 10.2\share\charsets\<br>check_constraint_checks, ON<br><strong>collation_connection, utf8mb4_general_ci</strong><br>collation_database, utf8mb4_unicode_ci<br>collation_server, utf8mb4_unicode_ci<br>completion_type, NO_CHAIN<br>concurrent_insert, AUTO<br>connect_timeout, 10</pre><p>collation_connection=utf8mb4_general_ci가 이상합니다. 설정 파일을 아무리 변경해도 위의 결과는 바뀌지 않았습니다.</p><p>결국 MySqlConnector 소스를 뒤져보니 이상한 부분이 발견되었습니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f053770306446a5a60ee786fd2ca0565/href">https://medium.com/media/f053770306446a5a60ee786fd2ca0565/href</a></iframe><p>MySqlConnector는 접속 절차를 다 거친 후 마지막에 SET NAMES utf8mb4; 명령어을 전송하고 있군요. 이제야 이해가 되었습니다.</p><p>그러고 나서 문서를 더 찾아보니 이런 내용이 나옵니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*r763nnq2470JFu9WhnefMg.png" /><figcaption>출처 : <a href="https://mysqlconnector.net/connection-options/">https://mysqlconnector.net/connection-options/</a></figcaption></figure><p>놀랍게도 utf8mb4 / utf8mb4_general_ci 고정인 라이브러리였습니다. 사실 <a href="https://mysqlserverteam.com/new-defaults-in-mysql-8-0/">MySQL 8.0의 기본 문자셋이 utf8mb4로 변경된 것</a>을 보면 놀랄 일도 아니긴 합니다만… 😅</p><p>사실 이 모든 문제의 시작은 HeidiSQL 때문이었습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*-lmnOqM13jq9SVOAN58tcQ.png" /></figure><p>설정 파일을 아무리 바꿔도 HeidiSQL에서는 상태가 바뀌지 않았습니다. 이제와서 생각해보니 HeidiSQL이 DB 서버에 접속하면서 character set 을 변경시킨 것이 아닐까 조심스레 추측해봅니다.</p><p>그리고 이렇게 collation_connection이 다르면 실행시 어떤 문제가 발생할 수 있는지도 알아봐야 할텐데요, 그건 다음에 다시 살펴볼려고 합니다. ( 살짝 조사해 봤을 때는 큰 문제는 없을 것 같았기에 … 😏 )</p><h4>References</h4><ul><li>What Are Character Sets and Collations<br><a href="https://mariadb.com/kb/en/character-set-and-collation-overview/">https://mariadb.com/kb/en/character-set-and-collation-overview/</a></li><li>Setting Character Sets and Collations<br><a href="https://mariadb.com/kb/en/setting-character-sets-and-collations/">https://mariadb.com/kb/en/setting-character-sets-and-collations/</a></li><li>About the Server System Variables<br><a href="https://mariadb.com/kb/en/server-system-variables/#character_set_server">https://mariadb.com/kb/en/server-system-variables/</a></li><li>SET NAMES <br><a href="https://mariadb.com/kb/en/set-names/">https://mariadb.com/kb/en/set-names/</a></li><li>(정광섭님) MySQL 기본 캐릭터 셋 설정하기 — RHEL/CentOS/Ubuntu<br><a href="https://www.lesstif.com/pages/viewpage.action?pageId=20775198">https://www.lesstif.com/pages/viewpage.action?pageId=20775198</a></li><li>(라엘님) utf8mb4 언어셋 소개 및 표현범위<br><a href="https://blog.lael.be/post/917">https://blog.lael.be/post/917</a></li><li>MySQL Character set 처리<br><a href="http://intomysql.blogspot.com/2010/12/mysql-character-set.html">http://intomysql.blogspot.com/2010/12/mysql-character-set.html</a></li><li>[MySqlConnector] MySQL .NET Connection String Options<br><a href="https://mysqlconnector.net/connection-options">https://mysqlconnector.net/connection-options</a></li><li>Below is every single defined Unicode character, organized by Codepoints,<br><a href="http://www.isthisthingon.org/unicode/allchars1.php">http://www.isthisthingon.org/unicode/allchars1.php</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da7624958624" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oldbeedev/mysql-utf8mb4-character-set-%EC%84%A4%EC%A0%95%ED%95%98%EA%B8%B0-da7624958624">[MariaDB] Setting utf8mb4 Character Set</a> was originally published in <a href="https://medium.com/oldbeedev">OldbeeDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[C#] How to monitor CPU, Memory, Disk Usage?]]></title>
            <link>https://medium.com/oldbeedev/c-how-to-monitor-cpu-memory-disk-usage-in-windows-a06fc2f05ad5?source=rss----2cdc9c37f155---4</link>
            <guid isPermaLink="false">https://medium.com/p/a06fc2f05ad5</guid>
            <category><![CDATA[wmi]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[김정환(John.Kim)]]></dc:creator>
            <pubDate>Mon, 24 Feb 2020 16:01:28 GMT</pubDate>
            <atom:updated>2020-03-06T09:16:17.453Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FJZHHe3_J4Bu4d9WGj7NXA.jpeg" /><figcaption>Image by <a href="https://pixabay.com/users/3844328-3844328/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1863880">Lorenzo Cafaro</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1863880">Pixabay</a></figcaption></figure><p>Windows + .NET Core 기반으로 서버를 구현하고 있습니다. 서버 리소스를 모니터링하고 최근 이력을 관리하는 기능이 요구되어 그 구현 방법을 간단히 정리해 보고자 합니다.</p><p>구현할 항목은 아래와 같습니다.</p><ul><li>전체 CPU 사용률</li><li>서버 Process CPU 사용률</li><li>Memory 사용률, 전체 Memory 크기, 사용한 Memory 크기</li><li>Disk 사용률, 전체 Disk 크기, 사용한 Disk 크기</li><li>서버 Process의 Commit Memory 크기, Handle 개수, Thread 개수</li></ul><h4>WMI 패키지 설치</h4><p>CPU 사용률, Memory 사용률, Disk 사용률 등과 같이 시스템 전반에 대한 성능 데이터는 Windows Management Instrumentation (이하 WMI) 을 통해 알아낼 수 있습니다.</p><p>WMI는 Windows 전용 기능이기 때문에 .NET Core에서 포함되어 있지 않습니다. NuGet Packages 를 통해 <strong>System.Management </strong>를 설치해야 합니다. 현재 최신 버전은 4.7.0 입니다. 아래 그림을 참고하시길 바랍니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*k_W9-m9j-HxtCPMPazjbXQ.png" /></figure><p>그리고 Windows Management Instrumentation 서비스가 Running 상태임을 확인해야 합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DryZl9Z4ozqRBL8Os9A8Sg.png" /></figure><h4>전체 CPU 사용률</h4><p>PowerShell에서 아래와 같이 Win32_PerfFormattedData_PerfOS_Processor 클래스를 조회하면 CPU당 사용률을 알 수 있습니다.</p><pre><strong>PS </strong>C:\Users\john&gt; <strong>Get-CimInstance -ClassName Win32_PerfFormattedData_PerfOS_Processor | select Name,PercentProcessorTime</strong></pre><pre>Name   PercentProcessorTime<br>----   --------------------<br>0                         6<br>1                         6<br>2                         0<br>3                         0<br>4                         0<br>5                         0<br>6                         0<br>7                         6<br>_Total                    2</pre><p>C# 으로 구현하면 아래와 같습니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5724ea5804c0bc579fb6c0a5dabbc81b/href">https://medium.com/media/5724ea5804c0bc579fb6c0a5dabbc81b/href</a></iframe><p>_Total 항목만 사용해도 되지만, 저는 CPU0~CPUx 의 평균을 구했습니다. 후자의 경우는 소수점 아래 1자리까지 값이 나와서 좀더 상세한 정보라는 느낌을 줍니다.</p><h4>Process 사용률</h4><p>Win32_PerfFormattedData_Perf<strong>Proc_Process</strong> 클래스를 조회하면 프로세스 별 CPU 사용률을 알 수 있습니다. 아래 그림을 보면 Idle 항목이 788로서 거의 800% 쯤 됩니다. 이는 제 PC의 CPU 개수 8개 *100% 한 값입니다.</p><pre><strong>PS </strong>C:\Users\john&gt; <strong>Get-CimInstance -ClassName Win32_PerfFormattedData_PerfProc_Process | select Name,PercentProcessorTime</strong></pre><pre>Name                    PercentProcessorTime<br>----                    --------------------<br>ASDSvc                  0<br>ConferenceServer        0<br>Evernote                0<br>EvernoteClipper         0<br>...<br>Idle                    <strong>788</strong><br>...</pre><p>C# 으로 구현하면 아래와 같습니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3388432bfc971ab556f8b85b581aeb58/href">https://medium.com/media/3388432bfc971ab556f8b85b581aeb58/href</a></iframe><p>procTime을 CPU 개수로 나누어 주고 있습니다.</p><h4>Momory 사용률</h4><p>Win32_OperatingSystem 클래스를 조회하면 OS 이름, OS 버전, PC 이름, Memory 사용량 등의 정보를 알 수 있습니다.</p><pre><strong>PS </strong>C:\Users\john&gt; <strong>Get-CimInstance -ClassName Win32_OperatingSystem | select *Memory*</strong></pre><pre>FreePhysicalMemory     : 9972352<br>FreeVirtualMemory      : 22933856<br>MaxProcessMemorySize   : 137438953344<br>TotalVirtualMemorySize : 34432340<br>TotalVisibleMemorySize : 16606548</pre><p>C# 으로 구현하면 아래와 같습니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/860517a27f1f208cb459eaf987a7b28c/href">https://medium.com/media/860517a27f1f208cb459eaf987a7b28c/href</a></iframe><p>TotalVisibleMemorySize 항목이 전체 Momory 크기, FreePhysicalMemory 항목이 남은 Momory 크기입니다. 이 두 정보를 이용해서 사용률 및 사용한 Momory 크기를 계산합니다.</p><h4>Disk 사용률</h4><p>Disk 사용량 역시 WMI로 조회할 수 있지만, DriverInfo 클래스를 사용하면 좀 더 간단한 것 같습니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c84510182886f5c651d889ad9d344722/href">https://medium.com/media/c84510182886f5c651d889ad9d344722/href</a></iframe><p>프로그램 실행 경로에 해당하는 드라이브를 찾아서 전체 Disk 크기 및 남은 Disk 크기를 알아냅니다. 이 두 정보를 이용해서 사용률 및 사용한 Disk 크기를 계산합니다.</p><h4>Process의 Commit Memory 크기, Handle 개수, Thread 개수</h4><p>서버 Process의 Memory 누수 여부를 알기 위해 Commit Memory의 추이를 확인할 필요가 있습니다. Handle 리소스나 Thread 역시 과다하게 생성되는지 확인해야 합니다. 다행히 구현은 매우 쉽습니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c5341b154ff4c5110024e46b09d6c17/href">https://medium.com/media/1c5341b154ff4c5110024e46b09d6c17/href</a></iframe><h4>vs. PerformanceCounter API</h4><p>WMI 대신 PerformanceCounter API를 사용할 수 도 있습니다. 그러나 몇 가지 불편한 점이 있었습니다.</p><ul><li>이 API로는 전체 Memory 크기를 알 수 없었습니다.</li><li>Memory 구분도 Committed, Paged 등으로 세세하게 구분되어 있어서 내용 파악이 좀 힘듭니다.</li><li>Process별 CPU 사용률이 WMI에 비해 편차가 좀 큰 것 같습니다.</li><li>NextValue() 메소드가 상태 값을 리턴하는 메소드입니다만, 아래와 같이 두번씩 불러줘야 하는 점이 약간 불편합니다.</li></ul><pre>cpuCounter.NextValue();           // Start <br>await Task.Delay(1000);           // 잠시 시간 지연을 해줘야 합니다.<br>var cpu = cpuCounter.NextValue(); // 사용률이 계산되어 리턴. <br>return cpu;</pre><h4>Limitation</h4><p>.NET Core 기반임에도 불구하고 WMI 및 PerformanceCounter 등은 윈도우 전용 패키지입니다. 만약 이 서버 프로그램을 Linux 상에서 돌리면 런타임에 exception이 발생할 것으로 예상됩니다. 이에 대한 API 레벨의 해결책은 아직 찾지 못했습니다.</p><h4>References</h4><ul><li><a href="https://medium.com/@jackwild/getting-cpu-usage-in-net-core-7ef825831b8b">Getting CPU usage % in .NET Core </a>(PerformanceCounter 및 TotalProcessorTime 사용하는 방법)</li><li><a href="https://gunnarpeipman.com/dotnet-core-system-memory/">Reading Windows and Linux memory metrics with .NET Core</a> (윈도우즈와 리눅스에서 메모리 사용률 알아내기)</li><li><a href="https://stackoverflow.com/questions/57121875/what-can-i-do-about-wmic-is-deprecated">What can I do about “WMIC is deprecated”?</a> (이젠 wmic 프로그램 대신 Get-CimInstance 사용하길 권장)</li><li><a href="https://www.sysnet.pe.kr/2/0/1850">작업 관리자에서의 “Commit size”가 가리키는 메모리의 의미</a> (정성태 님 블로그)</li></ul><p>끝 : )</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a06fc2f05ad5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oldbeedev/c-how-to-monitor-cpu-memory-disk-usage-in-windows-a06fc2f05ad5">[C#] How to monitor CPU, Memory, Disk Usage?</a> was originally published in <a href="https://medium.com/oldbeedev">OldbeeDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[C#]  ProcessStartInfo.WindowStyle = Hidden vs. CreateNoWindow = true]]></title>
            <link>https://medium.com/oldbeedev/c-processstartinfo-windowstyle-hidden-vs-createnowindow-true-22b82d85cf1f?source=rss----2cdc9c37f155---4</link>
            <guid isPermaLink="false">https://medium.com/p/22b82d85cf1f</guid>
            <category><![CDATA[useshellexecute]]></category>
            <category><![CDATA[processstartinfo]]></category>
            <category><![CDATA[createnowindow]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[김정환(John.Kim)]]></dc:creator>
            <pubDate>Mon, 17 Feb 2020 04:09:00 GMT</pubDate>
            <atom:updated>2020-02-17T14:41:39.134Z</atom:updated>
            <content:encoded><![CDATA[<h3>[C#] ProcessStartInfo.WindowStyle = Hidden vs. CreateNoWindow = true</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*LcckH0kbroaQXfBz6XUACg.png" /><figcaption><a href="http://www.firststeps.ru/mfc/winapi/r.php?131">http://www.firststeps.ru/mfc/winapi/r.php?131</a></figcaption></figure><p>외부 프로그램을 실행시키는 가장 간단한 방법은 Process.Start(파일경로)를 호출하는 것입니다. 그리고 외부 프로그램을 숨김 상태로 실행시키는 방법은 <a href="https://medium.com/oldbeedev/c-run-console-program-with-process-start-9440dd38e843">앞선 문서</a>에서 설명한 바와 같이 WindowStyle=Hidden 옵션을 사용하는 것입니다. 숨김 상태로 실행하는 또 다른 방법도 있는데 바로 CreateNoWindow 옵션을 사용하는 것입니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b065aefd5d3e1a04b8ac6d6afbd5c8f/href">https://medium.com/media/7b065aefd5d3e1a04b8ac6d6afbd5c8f/href</a></iframe><p>CreateNoWindow=true가 적용되려면 반드시 UseShellExecute=false여야 한다고 합니다. 이 둘의 차이점을 검색해 보면 여러 가지가 나옵니다만, 말로는 잘 이해가 안되서 소스 코드를 직접 확인해 보았습니다.</p><h3>.NET Reference Source</h3><p>소스 코드의 위치는 아래와 같습니다.</p><blockquote><a href="https://github.com/microsoft/referencesource/blob/master/System/services/monitoring/system/diagnosticts/Process.cs">https://raw.githubusercontent.com/microsoft/referencesource/master/System/services/monitoring/system/diagnosticts/Process.cs</a></blockquote><p>Process.cs를 살펴보면 PeakMemorySize, Standard Input/Output/Error, processorAffinity 등의 어려운(?) 용어들이 나오지만 제 관심사는 아닌 것 같아서 모두 스킵하고 곧장 Start() 메소드를 살펴봅니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fcc96865115af5263f17faa226d8763c/href">https://medium.com/media/fcc96865115af5263f17faa226d8763c/href</a></iframe><p>UseShellExecute 값에 따라 서로 다른 메소드가 호출됩니다. 이름만 봐서는 한 놈은 ShellExecute를 사용하는 것이고 다른 한 놈은 CreateProcess를 사용하는 것 같습니다.</p><h3>StartWithShellExecuteEx</h3><p>StartWithShellExecuteEx() 메소드의 대략적인 흐름은 다음과 같습니다.</p><ol><li>사전 조건 체크 (사용자 권한, Pipe연결, 환경 변수)</li><li>Window Style 적용</li><li>실행 파일 문자열 및 아규먼트 문자열 처리</li><li>ShellExecuteEx API가 호출됨</li><li>기타 뒷 처리</li></ol><p>UseShellExecute=true일 때는 ShellExecuteEx API가 사용되며, ProcessWindowStyle.Hidden 값은 이 API와 연관된 파라미터임을 알 수 있습니다.</p><h3>StartWithCreateProcess</h3><p>StartWithCreateProcess() 메소드의 코드 구조는 다음과 같습니다.</p><ol><li>command line 문자열 생성</li><li>STARTUPINFO 구조체 생성</li><li>이 부분에서 CreateNoWindow 옵션 처리 <br><em>if (startInfo.CreateNoWindow) <br> creationFlags |= NativeMethods.CREATE_NO_WINDOW;</em></li><li>CreateProcess 실행<br> UserName이 입력되었으면 CreateProcessWithLogon API가 호출됨,<br> 그 외에는 CreateProcess API가 호출됨</li><li>기타 뒷 처리</li></ol><p>UseShellExecute=false일 때는 CreateProcess API가 사용되며 CreateNoWindow 옵션은 이 API와 관련된 파라미터임을 알 수 있습니다.</p><h3>성능 비교</h3><p>Version1과 Version2의 성능 차이가 궁금해서 간단히 테스트를 해봤습니다. 프로세스를 100개씩 생성하는데 걸리는 시간을 측정했습니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4917fcabdb9895bffda7a4eec99e1377/href">https://medium.com/media/4917fcabdb9895bffda7a4eec99e1377/href</a></iframe><h4>Results</h4><blockquote>StartWithHiddenStyle running time = 2187 ms<br>StartWithCreateNoWindow running time = 696 ms</blockquote><blockquote>StartWithHiddenStyle running time = 4538 ms<br>StartWithCreateNoWindow running time = 676 ms</blockquote><blockquote>StartWithHiddenStyle running time = 4151 ms<br>StartWithCreateNoWindow running time = 680 ms</blockquote><blockquote>StartWithHiddenStyle running time = 3669 ms<br>StartWithCreateNoWindow running time = 708 ms</blockquote><blockquote>StartWithHiddenStyle running time = 3005 ms<br>StartWithCreateNoWindow running time = 760 ms</blockquote><p>대략 StartWithCreateNoWindow가 3배~6배 정도 빠릅니다. CreateProcess API가 더 Low Level이므로 당연한 결과일 것입니다.</p><h3>.NET Core에서는?</h3><p>ShellExecuteEx는 윈도우 셸 API 인데 linux 기반에서 돌까? 하는 궁금증이 생겼는데 조금 찾아보니 과연 여러 이야기가 있는 것 같습니다. 이 부분도 소스를 확인해보면 좀 더 구체적으로 알 수 있을 것입니다.</p><blockquote><a href="https://github.com/dotnet/runtime/tree/master/src/libraries/System.Diagnostics.Process/src/System/Diagnostics">https://github.com/dotnet/runtime/tree/master/src/libraries/System.Diagnostics.Process/src/System/Diagnostics</a></blockquote><p>그러나 지금은 제가 시간이 없으므로 다음에 정리하도록 하겠습니다. ;)</p><p>끝!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22b82d85cf1f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oldbeedev/c-processstartinfo-windowstyle-hidden-vs-createnowindow-true-22b82d85cf1f">[C#]  ProcessStartInfo.WindowStyle = Hidden vs. CreateNoWindow = true</a> was originally published in <a href="https://medium.com/oldbeedev">OldbeeDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[C#] Run console program with Process.Start]]></title>
            <link>https://medium.com/oldbeedev/c-run-console-program-with-process-start-9440dd38e843?source=rss----2cdc9c37f155---4</link>
            <guid isPermaLink="false">https://medium.com/p/9440dd38e843</guid>
            <category><![CDATA[process]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[cmd]]></category>
            <dc:creator><![CDATA[김정환(John.Kim)]]></dc:creator>
            <pubDate>Thu, 13 Feb 2020 19:18:49 GMT</pubDate>
            <atom:updated>2020-02-13T20:10:17.255Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cTnwT7B6YDbiHxIHYHY2zQ.jpeg" /><figcaption>Image by <a href="https://pixabay.com/users/geralt-9301/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=368719">Gerd Altmann</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=368719">Pixabay</a></figcaption></figure><p>C#에서 외부 프로그램을 실행시키는 방법은 간단합니다.</p><pre>string ftpClient = &quot;C:\\Program Files (x86)\\WinSCP\\WinSCP.exe&quot;;<br>Process.Start(ftpClient);</pre><p>외부 프로그램이 Console 프로그램이라도 방법은 같습니다.</p><pre>string path = @&quot;C:\Samples\snmp_trapd\snmptrapd.exe&quot;;<br>Process.Start(path);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*mkiDhnFwQjcga6l436oGLw.png" /></figure><p>그런데 이 외부 프로그램은 SNMP trap daemon 이라서 계속 running 상태여야 하는데, 위와 같이 CMD창으로 띄워 놓으면 실수로 닫기가 쉽습니다. 이럴 때 아래와 같이 WindowStyle 속성을 Hidden으로 지정해서 Start하면 CMD 창이 안보이게 띄울 수 있습니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a447db10b9b7ba1682e4f535ded60fc0/href">https://medium.com/media/a447db10b9b7ba1682e4f535ded60fc0/href</a></iframe><p>만약 MainWindow를 종료할 때 SNMP trap daemon도 함께 종료시키고 싶으면 다음과 같이 Process.Kill() 메소드를 사용합니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c56a4fd719a9608364402eaf9a60a6bc/href">https://medium.com/media/c56a4fd719a9608364402eaf9a60a6bc/href</a></iframe><p>최근에는 프로그램에서 xcopy를 실행해야 하는 상황도 있었습니다. 당연히 Hidden으로 실행을 시켰습니다만, xcopy가 언제 종료되는지 모른다는 문제가 생겼습니다. 이럴 때는 다음과 같이 Process.WaitForExit() 메소드를 사용해야 합니다.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac844f572a3e07b16aee143f2cec0f0a/href">https://medium.com/media/ac844f572a3e07b16aee143f2cec0f0a/href</a></iframe><p>위의 XCopy() 메소드를 호출하는 방법은 아래와 같습니다.</p><pre>string srcPath = @&quot;C:\Samples\snmp_trapd&quot;;<br>string dstPath = @&quot;C:\Samples\snmp_trapd_backup&quot;;</pre><pre>if (XCopy(srcPath, dstPath))<br>{<br>  MessageBox.Show(&quot;success&quot;);<br>}<br>else<br>{<br>  MessageBox.Show(&quot;fail&quot;);<br>}</pre><p>snmp_trapd 디렉토리 및 하위 디렉토리의 모든 파일들이 snmp_trapd_backup 디렉토리로 복사되고 나면 “success” 팝업이 뜹니다.</p><p>끝! :)</p><h4>References</h4><ul><li><a href="https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy">xcopy 명령어 사용법</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9440dd38e843" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oldbeedev/c-run-console-program-with-process-start-9440dd38e843">[C#] Run console program with Process.Start</a> was originally published in <a href="https://medium.com/oldbeedev">OldbeeDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Alternative to Dependency Walker]]></title>
            <link>https://medium.com/oldbeedev/alternative-to-dependency-walker-51ca61189ef?source=rss----2cdc9c37f155---4</link>
            <guid isPermaLink="false">https://medium.com/p/51ca61189ef</guid>
            <category><![CDATA[dll]]></category>
            <category><![CDATA[dependency-walker]]></category>
            <category><![CDATA[how-to]]></category>
            <dc:creator><![CDATA[김정환(John.Kim)]]></dc:creator>
            <pubDate>Sun, 09 Feb 2020 16:22:51 GMT</pubDate>
            <atom:updated>2020-02-18T20:33:48.346Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*_tiW8P7VPhmnzvC7vSaZEg.png" /><figcaption>출처 : dependencywalker</figcaption></figure><p>오래전 일이지만, VC++ 함수를 export할 때 extern “C”를 안해서 name mangling 문제로 “entry point not found” 에러를 겪은 적이 있습니다. MFC로 UI를 개발하고 인스톨본을 만들어 배포할 때도 dll이 누락되어 런타임에 낭패를 겪는 경우가 종종 있었지요.</p><p>이런 일이 있을 때마다, Dependency Walker를 실행시켜서 누락된 dll이 뭔지 확인하곤 했습니다. 이 프로그램은 Visuaul Studio나 SDK에 포함되어 배포되었던 것으로 기억합니다.</p><p>시간이 흘러 C#/WPF/.NET Core 로 넘어와서 일을 하다보니, 점점 이 프로그램을 사용하는 빈도가 줄어들었습니다. 그러다가 나중에서야 이 프로그램이 제대로 동작하지 않는다는 사실을 알았습니다. (2006년 즈음부터 개발이 중단되었다고 합니다.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*MxtaF11FZk4apsGzSQQPmA.png" /></figure><p>못내 아쉬운 마음이 들어서, 조금 찾아보니 다행히 훌륭한 대체품이 있었습니다.</p><h3>Dependencies — An open-source modern Dependency Walker</h3><h4>설치순서</h4><ul><li><a href="https://github.com/lucasg/Dependencies/releases">https://github.com/lucasg/Dependencies/release</a>에서 최신본 (현재 v1.10)을 다운로드 받습니다. 저는 Dependencies_x64_Release.zip를 다운로드 받았습니다.</li><li>압축 파일을 풀어서 <strong>DependenciesGui.exe</strong>를 실행합니다. 최초 실행시 아래와 같은 SmartScreen이 뜰 수 있습니다. [실행]을 선택합니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/0*QCkRmo144or7zQFJ" /></figure><h4>사용법</h4><ul><li>Dependencie 프로그램에 .exe파일이나 .dll 파일을 드래그앤드랍 해보면 아래와 같이 dll 목록이 쫘악 뜹니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UfAAha2v-kLtfEOB1_GwvQ.png" /></figure><ul><li>테스트 삼아 Newtonsoft.Json.dll 을 이름을 변경한 후 Dependencies에서 Refresh(=F5) 해보면 아래 그림과 같이 해당 dll을 찾을 수 없다는 표시가 뜹니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dAxefMM7DniF7VonXcLGqA.png" /></figure><p>좋네요~ 이 개발자에게 고마운 마음입니다. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51ca61189ef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oldbeedev/alternative-to-dependency-walker-51ca61189ef">Alternative to Dependency Walker</a> was originally published in <a href="https://medium.com/oldbeedev">OldbeeDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows에서 갑자기 한글 입력이 안될 때]]></title>
            <link>https://medium.com/oldbeedev/%EC%9C%88%EB%8F%84%EC%9A%B0%EC%A6%88%EC%97%90%EC%84%9C-%EA%B0%91%EC%9E%90%EA%B8%B0-%ED%95%9C%EA%B8%80-%EC%9E%85%EB%A0%A5%EC%9D%B4-%EC%95%88%EB%90%A0-%EB%95%8C-f27fcf7fa564?source=rss----2cdc9c37f155---4</link>
            <guid isPermaLink="false">https://medium.com/p/f27fcf7fa564</guid>
            <category><![CDATA[한글]]></category>
            <category><![CDATA[ctfmon]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[windows]]></category>
            <dc:creator><![CDATA[김정환(John.Kim)]]></dc:creator>
            <pubDate>Sat, 08 Feb 2020 11:14:58 GMT</pubDate>
            <atom:updated>2020-02-08T14:38:45.875Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KW2d50k6F0S1VHFkarnW3Q.png" /><figcaption>Photo by <a href="https://unsplash.com/@ariel_kwon?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Ariel Kwon</a> on <a href="https://unsplash.com/@ariel_kwon?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>잘 쓰던 윈도우즈에서 갑자기 한글 입력이 안될 때가 있습니다. 특히 브라우저에서 이런 경우가 종종 발생했던 것 같은데요, PC를 리부팅하면 해결되긴 하지만 좀 무식해 보이니 아래 방법을 먼저 시도해보면 좋을 것 같습니다.</p><p>윈도우키+R 을 실행해서 <strong>ctfmon</strong>을 입력하고 Enter를 칩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*DC-yTL2rEEh8Ahact_l9Yw.png" /></figure><p>이제 한글 입력이 잘 되는지 확인해 봅니다.</p><p>참고로 ctfmon.exe는 Microsoft Office와 함께 설치되는 프로그램으로서 한영전환을 담당합니다. 가끔 특정 프로그램과의 충돌 등으로 ctfmon 프로세스가 종료되면 이런 한영 전환 문제가 발생할 수 있다고 합니다.</p><p>끝 :)</p><h4>References</h4><ul><li><a href="https://studyforus.tistory.com/106">https://studyforus.tistory.com/106</a></li><li><a href="https://travelerstory.tistory.com/157">https://travelerstory.tistory.com/157</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f27fcf7fa564" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oldbeedev/%EC%9C%88%EB%8F%84%EC%9A%B0%EC%A6%88%EC%97%90%EC%84%9C-%EA%B0%91%EC%9E%90%EA%B8%B0-%ED%95%9C%EA%B8%80-%EC%9E%85%EB%A0%A5%EC%9D%B4-%EC%95%88%EB%90%A0-%EB%95%8C-f27fcf7fa564">Windows에서 갑자기 한글 입력이 안될 때</a> was originally published in <a href="https://medium.com/oldbeedev">OldbeeDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to find out DefaultUpdateSourceTrigger by coding?]]></title>
            <link>https://medium.com/oldbeedev/wpf-databinding-updatesourcetrigger-default%EB%A5%BC-%EC%BD%94%EB%94%A9%EC%9C%BC%EB%A1%9C-%EC%95%8C%EC%95%84%EB%82%B4%EA%B8%B0-8252c9e88f31?source=rss----2cdc9c37f155---4</link>
            <guid isPermaLink="false">https://medium.com/p/8252c9e88f31</guid>
            <category><![CDATA[updatasourcetrigger]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[wpf]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[김정환(John.Kim)]]></dc:creator>
            <pubDate>Wed, 05 Feb 2020 20:58:35 GMT</pubDate>
            <atom:updated>2020-02-10T10:51:45.538Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PQYhWFqW6Qk8kKC7de108A.png" /><figcaption><a href="https://burst.shopify.com/photos/stacks-of-hardback-books">©Samantha Hurley</a></figcaption></figure><p>WPF Data Binding에서 UpdateSourceTrigger는 다음과 같이 4가지 옵션이 있습니다.</p><ol><li>PropertyChanged : Target Property 입력값이 변경될 때마다.</li><li>LostFocus : Target 객체에서 다른 객체로 포커스가 이동될 때.</li><li>Explicit : 명시적으로 UpdateSource() 메소드를 호출할 때만.</li><li>Default : Target Property 별로 정의된 바인딩 기본값에 따름. 대부분은 PropertyChanged이고, TextBox.Text 속성은 LostFocus가 기본값임.</li></ol><p>4번 Default 인 경우, “대부분은 PropertyChanged가 기본값” 이라고 얘기하고 있지만 MSDN에는 이 기본값에 대해 구체적인 정보가 없는 것 같습니다. 대신 코딩으로 조사해볼 수는 있습니다.</p><h3>DependencyProperty.GetMetadata 메소드</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b29512488422649f0ee6dc182382194/href">https://medium.com/media/7b29512488422649f0ee6dc182382194/href</a></iframe><p>CheckBox.IsChecked 속성의 metadata를 알아내려면 DependencyProperty인 IsCheckedProperty 에 대해 GetMetadata()를 호출합니다. CheckBox type을 파라미터로 넘기고 리턴값을 <a href="https://docs.microsoft.com/ko-kr/dotnet/api/system.windows.frameworkpropertymetadata?view=netframework-4.8">FrameworkProperyMetadata</a> 로 캐스팅해야 합니다. 리턴되는 metadata에는 DefaultUpdateSourceTrigger 뿐만 아니라 BindsTwoWayByDefault (속성이 기본적으로 양방향 바인딩 되는지 여부) 등의 정보도 포함되어 있습니다.</p><p>WPF 기본 컨트롤 뿐만 아니라 DevExpress 같은 상용 컴포넌트의 컨트롤에 대해서도 같은 방식으로 DefaultUpdateSourceTrigger 및 BindsTwoWayByDefault를 알아낼 수 있습니다.</p><p>만약 TextBox.Text 속성에 바인딩된 변수가 입력 즉시 갱신되기를 바란다면 아래와 같이 명시적으로 UpdateSourceTrigger=PropertyChanged 를 지정해주어야 합니다.</p><pre>&lt;TextBox Text=&quot;{Binding Name, <br>         Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}&quot; /&gt;</pre><p>참고로 TextBox.Text는 기본적으로 양방향 바인딩이 되므로 Mode=TwoWay 는 불필요한 코드가 되겠습니다.</p><p>끝. 고맙습니다 :)</p><p>ps) 왠지 미디엄에서는 제목을 영어로 달아야 할 것 같은 분위기가 ㅎㅎㅎ</p><h4>References :</h4><ul><li><a href="https://wpf.2000things.com/tag/frameworkpropertymetadata/">https://wpf.2000things.com/tag/frameworkpropertymetadata/</a></li><li><a href="https://medium.com/oldbeedev/wpf-data-binding-concept-mode-updatesourcetrigger-648735b2444">https://medium.com/oldbeedev/wpf-data-binding-concept-mode-updatesourcetrigger-648735b2444</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8252c9e88f31" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oldbeedev/wpf-databinding-updatesourcetrigger-default%EB%A5%BC-%EC%BD%94%EB%94%A9%EC%9C%BC%EB%A1%9C-%EC%95%8C%EC%95%84%EB%82%B4%EA%B8%B0-8252c9e88f31">How to find out DefaultUpdateSourceTrigger by coding?</a> was originally published in <a href="https://medium.com/oldbeedev">OldbeeDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[XAML Styler]]></title>
            <link>https://medium.com/oldbeedev/xaml-styler-33349c13e3e8?source=rss----2cdc9c37f155---4</link>
            <guid isPermaLink="false">https://medium.com/p/33349c13e3e8</guid>
            <category><![CDATA[xaml]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[style]]></category>
            <dc:creator><![CDATA[김정환(John.Kim)]]></dc:creator>
            <pubDate>Sun, 02 Feb 2020 19:04:14 GMT</pubDate>
            <atom:updated>2020-02-17T15:11:16.318Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*oBgzzpaXyJzAbpy75VJqUw.jpeg" /><figcaption><a href="https://pixabay.com/illustrations/real-estate-concept-housing-village-3868287/">© AbsolutVision (pixabay)</a></figcaption></figure><p>XAML 코딩을 하다 보면 팀원간에 attrubute 순서나 attribute 줄바꿈 스타일이 달라서 가독성이 떨어지는 경우가 발생합니다. 이때 말이나 글로 coding guideline을 맞추다 보면 어느 순간 분위기가 싸~ 합니다. 이렇게 되기 전에 Tool을 사용하는 것이 깔끔합니다.</p><p><a href="https://github.com/Xavalon/XamlStyler">Xavalon/XamlStyler</a></p><h3>Installation</h3><p>XAML Styler extension 은 아래 링크에서 다운로드 받을 수 있습니다.</p><p><a href="https://marketplace.visualstudio.com/items?itemName=TeamXavalon.XAMLStyler">XAML Styler</a></p><p>다운로드 받은 XamlStyler.Package.vsix 파일을 더블클릭하면 설치가 진행됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*6_4uwAvP6CHPn4upbMMZVw.png" /></figure><p>설치가 완료되면 Visual Studio 2019를 실행합니다. XAML 소스 코드에서 마우스 오른쪽 버튼을 클릭하면 “Format XAML” 메뉴가 보입니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*n4Q5QTyMYWxfE0rw5U6CKg.png" /></figure><p>실행해보면 기본 옵션값에 따라 XAML 소스 코드의 줄바꿈이 변경되는 것을 볼 수 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*dubWgndv3iholHFLkGHkzQ.png" /></figure><h3>Configuration</h3><p>Visual Studio 2019의 메뉴 &gt; Tools &gt; Options &gt; XAML Styler 를 찾아보면 옵션을 원하는 대로 변경할 수 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*PoHRhnt1x94VH7b_o4YMdQ.png" /></figure><p>또는 스타일 옵션을 파일로 만들어서 팀원간에 공유할 수도 있습니다. 파일명은 Settings.XamlStyler 이며 .sln 파일과 같은 경로에 저장합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*qCZR5flDFfX3b3IS_IlQgQ.png" /></figure><p>제가 사용하는 Settings.XamlStyler 규칙은 아래와 같습니다. Bold 폰트로 표시된 부분이 기본값에서 변경된 옵션입니다. 스타일 옵션에 대한 상세한 설명은 <a href="https://github.com/Xavalon/XamlStyler/wiki/Configuration">XamlStyle Wiki 페이지</a>를 확인해보시길 바랍니다.</p><pre>{<br>    &quot;IndentSize&quot;:2, <br>    <strong>&quot;AttributesTolerance&quot;: 2,</strong><br>    <strong>&quot;KeepFirstAttributeOnSameLine&quot;: true,</strong><br>    &quot;MaxAttributeCharatersPerLine&quot;: 0,<br>    <strong>&quot;MaxAttributesPerLine&quot;: 4,</strong><br>    &quot;<strong>NewlineExemptionElements</strong>&quot;: &quot;RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransfom, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter, <strong>dxg:GridColumn, dxgcore:GridColumn, dxg:TreeListColumn</strong>&quot;,<br>    <strong>&quot;SeparateByGroups&quot;: true,</strong><br>    &quot;EnableAttributeReordering&quot;: true,<br>    &quot;<strong>AttributeOrderingRuleGroups</strong>&quot;: [<br>        &quot;x:Class*&quot;,<br>        &quot;xmlns, xmlns:x&quot;,<br>        <strong>&quot;xmlns:mc, xmlns:d&quot;,<br>        &quot;xmlns:dx*&quot;,<br>        &quot;xmlns:nv*&quot;,</strong><br>        &quot;xmlns:*&quot;,<br>        &quot;x:Key, Key, x:Name, Name, x:Uid, Uid, Title, Tag&quot;,<br>        &quot;Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan, Canvas.Left, Canvas.Top, Canvas.Right, Canvas.Bottom&quot;,<br>        &quot;Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight&quot;,<br>        &quot;Margin, Padding, HorizontalAlignment, VerticalAlignment, HorizontalContentAlignment, VerticalContentAlignment, Panel.ZIndex&quot;,<br>        &quot;Style, Background, Foreground, Fill, BorderBrush, BorderThickness, Stroke, StrokeThickness, Opacity&quot;,<br>        &quot;FontFamily, FontSize, LineHeight, FontWeight, FontStyle, FontStretch&quot;,<br>        &quot;*:*, *&quot;,<br>        &quot;PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint&quot;,<br>        <strong>&quot;mc:Ignorable, d:*&quot;</strong><br>    ],<br>    <strong>&quot;FirstLineAttributes&quot; : &quot;x:Name, x:Uid, x:Key&quot;,</strong><br>    <strong>&quot;OrderAttributesByName&quot;: true,</strong><br>    &quot;PutEndingBracketOnNewLine&quot;: false,<br>    &quot;RemoveEndingTagOfEmptyElement&quot;: true,<br>    &quot;SpaceBeforeClosingSlash&quot;: true,<br>    <strong>&quot;RootElementLineBreakRule&quot;: 1,</strong><br>    &quot;ReorderVSM&quot;: 2,<br>    &quot;ReorderGridChildren&quot;: false,<br>    &quot;ReorderCanvasChildren&quot;: false,<br>    &quot;ReorderSetters&quot;: 0,<br>    &quot;FormatMarkupExtension&quot;: true,<br>    &quot;NoNewLineMarkupExtensions&quot;: &quot;x:Bind, Binding&quot;,<br>    &quot;ThicknessSeparator&quot;: 2,<br>    &quot;ThicknessAttributes&quot;: &quot;Margin, Padding, BorderThickness, ThumbnailClipMargin&quot;,<br>    &quot;FormatOnSave&quot;: true,<br>    <strong>&quot;CommentPadding&quot;: 1</strong><br>}</pre><p>아래 그림은 위의 규칙을 적용한 결과입니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*0JHSBUZYqT3YKbxjmfa7Yg.png" /></figure><p>끝 :)</p><h4>Resources</h4><ul><li><a href="https://github.com/Xavalon/XamlStyler/wiki">XAML Styler Documentation</a></li><li><a href="https://github.com/Xavalon/XamlStyler/wiki/External-Configurations">XAML Styler External Configurations</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33349c13e3e8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oldbeedev/xaml-styler-33349c13e3e8">XAML Styler</a> was originally published in <a href="https://medium.com/oldbeedev">OldbeeDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[블로그 존댓말 vs 반말]]></title>
            <link>https://medium.com/oldbeedev/%EB%B8%94%EB%A1%9C%EA%B7%B8-%EC%A1%B4%EB%8C%93%EB%A7%90-vs-%EB%B0%98%EB%A7%90-1467d2778a7f?source=rss----2cdc9c37f155---4</link>
            <guid isPermaLink="false">https://medium.com/p/1467d2778a7f</guid>
            <dc:creator><![CDATA[김정환(John.Kim)]]></dc:creator>
            <pubDate>Sun, 02 Feb 2020 16:49:36 GMT</pubDate>
            <atom:updated>2020-02-02T16:49:36.609Z</atom:updated>
            <content:encoded><![CDATA[<p>블로깅 할 때 반말로 할 것이냐, 존댓말로 할 것이냐.</p><p>블로그를 나 혼자 보기 위한 용도라면 반말이 편하겠고,</p><p>다른 사람들에게 노출시키길 원하다면…. 고민이 시작됩니다.</p><p>고민을 10분 정도 했는데요,</p><p>2020년부터는 존댓말을 쓰기로 했습니다.</p><p>좋은 밤 되세요</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1467d2778a7f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oldbeedev/%EB%B8%94%EB%A1%9C%EA%B7%B8-%EC%A1%B4%EB%8C%93%EB%A7%90-vs-%EB%B0%98%EB%A7%90-1467d2778a7f">블로그 존댓말 vs 반말</a> was originally published in <a href="https://medium.com/oldbeedev">OldbeeDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kill the XAML Designer]]></title>
            <link>https://medium.com/oldbeedev/kill-the-xaml-designer-ed80ef437edf?source=rss----2cdc9c37f155---4</link>
            <guid isPermaLink="false">https://medium.com/p/ed80ef437edf</guid>
            <category><![CDATA[xdesproc]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[xaml]]></category>
            <dc:creator><![CDATA[김정환(John.Kim)]]></dc:creator>
            <pubDate>Fri, 31 Jan 2020 06:28:42 GMT</pubDate>
            <atom:updated>2020-01-31T06:36:13.626Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>아래 내용은 Visual Studio 2017 기준입니다. 2019에서는 XAML 디자이너가 Hang되는 경우가 거의, 아니 아직은 없었습니다.</blockquote><p>XAML 디자이너는 참 좋기는 한데, 가끔 Hang이 걸리는 경우가 발생한다. DynamicResource를 제대로 로딩하지 못하고 엑빡을 띄우는 경우도 가끔 있다. 그러다가 빌드할 때마다 Visual Studio 자체가 매우 느려지는 경우도 생긴다. 이렇게 되면 작업관리자를 열어서 XDesProc.exe 프로세스를 찾아 죽이고, XAML 디자이너로 돌아와서 ‘Click here to reload the designer’를 클릭했었다. 몇 번 반복하다 보면 이런 과정이 소모적으로 느껴지는데 이때 사용하면 좋은 Extension이 있다.</p><h3>Kill the WPF Designer</h3><p>이름 그대로 XAML 디자이너를 킬해주는 Extension이다. 설치를 위해 “메인 메뉴 : Tools” &gt; “Extensions and Updates” 를 선택한다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*N8BPoc_rM70lkyUwOGv6tQ.png" /></figure><p>Extensions 관리창에서 “Online”을 선택하고, 검색어에 “Kill”을 입력하면 아래와 같이 검색 결과가 뜬다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*Oq_APQgbY6rksWe2YLHRlw.png" /></figure><p>“Download” 버튼으로 다운을 받은 후, Visual Studio를 끄면 Extension 설치가 진행된다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*i6lOEWskOQtC1yEICUj06g.png" /></figure><p>Visual Studio를 다시 띄우고 WPF 프로젝트를 열어보면 아래와 같이 섬뜩한! 스크림 아이콘이 보인다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*6Z92mmU9DKmCx5RTrR6Mmw.png" /></figure><p>과감히 이 아이콘을 클릭해보자. 모든 XDesProc.exe 프로세스가 킬되고, XAML 디자이너 화면은 아래와 같이 바뀔 것이다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*Ll8QSRvsh6suRs2Ck1jEDA.png" /></figure><p>“Click here to reload the designer” 를 클릭해서 XAML 디자이너를 리로딩한다.</p><h3>Wrapup :</h3><p>아래의 번뜩이는 개발자에게 감사드리며…😉</p><h4>References :</h4><p><a href="https://github.com/JohanLarsson/KillWpfDesigner">JohanLarsson/KillWpfDesigner</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed80ef437edf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oldbeedev/kill-the-xaml-designer-ed80ef437edf">Kill the XAML Designer</a> was originally published in <a href="https://medium.com/oldbeedev">OldbeeDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>