반응형
기본적으로 위와 같은 프로세스를 거치도록 되어 있음.
<시나리오>
OPEN API 에서 종목별 REAL 현재가가 업데이트 될 때 이것을 DB 화 하고
각 차트에 이 DB 를 사용해서 업데이트 하라고 하기 위해 이벤트를 전달 하기 위해 사용함
이벤트가 발생하는 클래스에 외부로 부터 이벤트 핸들러 함수를 받을 수 있도록 예를들어 이런 함수들을 만든다.
public delegate void price_update_handler(RealPriceEventArgs e);
public event price_update_handler m_price_update_handler;
public void SetPriceEventHandler(ref price_update_handler priceHandler)
{
if (priceHandler != null)
{
m_price_update_handler -= priceHandler;
m_price_update_handler += priceHandler;
}
}
public void ClearPriceEventHandler(ref price_update_handler priceHandler)
{
m_price_update_handler -= priceHandler;
}
가격 이벤트가 발생하는 곳에서 호출
RealPriceEventArgs evtRealPrice = new RealPriceEventArgs();
m_price_update_handler(evtRealPrice);
호출하여 이벤트 받을 곳에서의 처리
// 이벤트 등록
SetPriceEventHandler(m_real_time_chart.eventHandler_price);
public void eventHandler_price(RealPriceEventArgs e)
{
// 가격 이벤트 처리
}
반응형
'Development > Visual C#' 카테고리의 다른 글
System.Runtime.InteropServices.COMException (0x80040154): 클래스가 등록되지 않았습니다. (예외가 발생한 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)) (0) | 2023.07.06 |
---|---|
[C#] Excel 생성/읽기 데이터 저장하기 (1) | 2022.10.05 |
[C#] Kiwoom 로그인 수동 제어 (0) | 2022.09.13 |
[C#] Thread 생성 하기 (0) | 2021.07.16 |
[C#] System.InvalidOperationException 에러 (0) | 2021.07.16 |
댓글