// ReqDlg.cpp : implementation file
//

#include "stdafx.h"
#include "sutl.h"
#include "ReqDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CReqDlg dialog


CReqDlg::CReqDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CReqDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CReqDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CReqDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CReqDlg)
	DDX_Control(pDX, IDC_REQLIST, m_listReq);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CReqDlg, CDialog)
	//{{AFX_MSG_MAP(CReqDlg)
	ON_BN_CLICKED(IDC_BCLOSE, OnBclose)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CReqDlg message handlers

void CReqDlg::OnBclose() 
{
	m_eventClose.SetEvent();	
}


void CReqDlg::WaitForClose()
{
     MSG msg;
     INT iCount=0;
     
     while (::WaitForSingleObject(m_eventClose,500) != WAIT_OBJECT_0) {
          while (::PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
               TranslateMessage(&msg);
               DispatchMessage(&msg);
          }
          iCount++;
          if (iCount > 29) {            // Wait for 30 seconds.
               break;
          }
     }
}
