bErrGHJ = WriteFile(hDFile, LpAll, Bytes_that_need_To_Write - bytes_which_have_written_already, &bytes_which_have_written_already, NULL);
WaitForConsumer()
typedef std::function < void(const char*,int) > ConsumerCallback; class first { void ConsumeMessage(ConsumerCallback callback); }; void ConsumeMessage(ConsumerCallback callback) { .... used ConsumerCallback } class second { boost::thread *start; bool isThreadInterrupt; void WaitForConsumer(const char* message, const int& length); void Test(); void start(); void stop(); }; second() { isThreadInterrupt = true; } void WaitForConsumer(const char* message, const int& length) { start = new boost::thread(&second::Start, this); start->join(); printf("isThreadInterrupt: %d\n", isThreadInterrupt); } void start() { if(condition) isThreadInterrupt = true; else isThreadInterrupt = false; } void stop() { // Thread already ended when joined in WaitForConsumer() // so cannot call interrupt() and join() // start->interrupt(); // start->join(); } void Test() { first obj; // inside WaitForConsumer will spawn a thread. obj.ConsumeMessage(std::bind(&second::WaitForConsumer, this, std::placeholders::_1, std::placeholders::_2)); }
startThread->join();
join()
ConsumeMessage()
isThreadInterrupt
std::thread *startThread= new std::thread([&](){ while(isThreadInterrupt) // set it to false to stop the while loop { obj.ConsumeMessage(std::bind(&second::WaitForConsumer, this, std::placeholders::_1, std::placeholders::_2)); } });
void printError( const TCHAR* msg )
BEGIN_MESSAGE_MAP(CChildView, CView) ON_WM_SIZE() // add this line to your message map END_MESSAGE_MAP() void CChildView::OnSize(UINT nType, int cx, int cy) { CView::OnSize(nType, cx, cy); Invalidate(TRUE); // add this line to redraw your CChildView }