Wpf에서 Custom Control 을 만들 때 유심히 봐야 할 내용이 바로 static 생성자 안에서 정의하는 DefaultStyleKeyProperty.OverrideMetadata 일 것 같다. 내가 확실하게 번역한 내용인지는 모르겠으나 대충 의역한 내용에 따르면 DefaultStyleKeyProperty.OverrideMetadata 을 정의하지 않으면 Custom Control 에서 상속받는 부모 클래스의 기본 Style을 따르게 된다고 한다.즉, 나만의 Custom Control 에서 새로운 Style을 지정하기 위해선 static 생성자에서 반드시 DefaultStyleKeyProperty.OverrideMetadata 를 정의해 줘야 한다.그리고 Style을 지정해주는 .xaml 파일은 ..
원래 중점 이슈는 WaitHandle.WaitAll(WaitHandle[]) 함수의 파라미터 변수 값의 64개 제한이었다. 64개의 제한 없이 모든 쓰레드의 처리를 기다린 후 뒤이어 진행을 바랬던 생각에서 파라미터 변수의 제한때문에 알아본 바를 기록한다.대안은 WaitHandle(AutoResetEvent, ManualResetEvent)의 Set() 과 WaitOne() 의 사용.ThreadPool 에서 사용하는 함수에서 WaitHandle 의 Set() 을 처리해 주고 주 스레드에서 WaitOne() 을 처리해 주는 형식. # 첨부 소스public class Fibonacci { private int _n; private int _fibOfN; private ManualResetEvent _doneE..
- AutoResetEvent 한번에 하나씩의 쓰레드 처리. 하나의 함수를 여러 쓰레드에서 처리할 때 첫 쓰레드에서 Reset() 으로 함수를 닫으면 다음 쓰레드가 차단되어 무한 대기. Set()으로 함수를 닫아줘야 다음 대기중인 쓰레드가 접근 가능 - ManualResetEvent 한번에 여러개의 쓰레드 처리 가능. 하나의 함수를 여러 쓰레드에서 처리할 때 첫 쓰레드에서 Reset() 으로 함수를 닫아도 한번에 여러개의 쓰레드가 처리 되기에 나머지 쓰레드도 처리됨. 단, Threading.Sleep(0)으로 해당 함수가 처리될 때 여러 쓰레드가 한번에 다 처리되는지 모르겠음. 예제 소스 출처는 http://j07051.tistory.com/560
[DllImport("user32.dll")] static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip, MonitorEnumDelegate lpfnEnum, IntPtr dwData); delegate bool MonitorEnumDelegate(IntPtr hMonitor, IntPtr hdcMonitor, ref Rect lprcMonitor, IntPtr dwData); [StructLayout(LayoutKind.Sequential)] public struct Rect { public int left; public int top; public int right; public int bottom; } /// /// The struct ..
배열 및 문자열이 포함된 구조체를 마샬링 하기 위해서는 MarshalAsAttribute 특성을 사용하여 포함된 문자열 및 배열을 마샬링 하는 방법을 지정해야한다. 그렇지 않으면 예외가 발생된다. (마샬링 하는 부분은 예외처리가 되어야한다!) 마샬링할 데이터비관리 구조체 (C++)관리 구조체 (C#)정수 배열view plaincopy to clipboardprint?struct MyStruct { int intArray[10]; }; view plaincopy to clipboardprint?struct MyStruct { [MarshalAsAttribute( UnManagedType.ByValArray, SizeConst = 10)] int[] intArray; } 문자 배열view plaincopy ..
using System; using System.Text; using System.Security.Cryptography; namespace test { class Program { static void Main(string[] args) { string a = "a"; UTF8Encoding u8e = new UTF8Encoding(); byte[] buf = u8e.GetBytes(a); SHA1 sha = new SHA1CryptoServiceProvider(); byte[] result = sha.ComputeHash(buf); Console.WriteLine(Convert.ToBase64String(result)); Console.ReadKey(); } } }
