केवल क्लाइंट आयत अपडेट करें


नमस्ते,

मैं एक बहु-थ्रेडेड एमएफसी एप्लिकेशन पर काम कर रहा हूं जिसे चित्र नियंत्रण पर एक ग्राफ़ बनाने की आवश्यकता है। सब कुछ लगता है

ठीक से काम करने के लिए, इस तथ्य के अलावा कि चित्र के लिए अमान्य फ़ंक्शन को कॉल करने पर चित्र नियंत्रण फिर से नहीं बनता है

नियंत्रण। यदि मैं संवाद पर अमान्य कहता हूं तो पूरी विंडो फिर से तैयार हो जाती है और झिलमिलाहट होती है। मैं कहां हूं इस पर कोई सुझाव

क्या मैं गलत हो रहा हूँ? मैंने यह कोशिश की है लेकिन इससे मदद नहीं मिली: http://computer-programming-forum.com/82-mfc/1d8b6d604dd7c393.htm

कोड:

सी++
DWORD WINAPI CDlg::WorkerThread(LPVOID lpVoid)
{
CDlg* appPtr = (CDlg*)lpVoid;
CStatic* pStatic = (CStatic*)appPtr->GetDlgItem(IDC_GRAPH_WINDOW);

while(true)
{
// Plotting graph
// Requires Update
appPtr->UpdatePoints(i);
pStatic->PostMessage(WM_PAINT);
}
}

समाधान 1

मुझे लगता है कि समस्या वर्कर थ्रेड से जीयूआई की पहुंच है। सही तरीके से कैसे करें यह जानने के लिए इस लेख पर एक नज़र डालें: वर्कर थ्रेड्स का उपयोग करना[^]

Worker threads and the GUI II: Don't touch the GUI

That's right. A worker thread must not touch a GUI object. This means that you should not query the state of a control, add something to a list box, set the state of a control, etc.

Why?

Because you can get into a serious deadlock situation. A classic example was posted on one of the discussion boards, and it described something that had happened to me last year. The situation is this: you start a thread, and then decide to wait for the thread to complete. Meanwhile, the thread does something apparently innocuous, such as add something to a list box, or, in the example that was posted, calls FindWindow. In both cases, the process came to a screeching halt, as all threads deadlocked.

समाधान 3

http://Www.hotboat.com/frm/member.php?u=12894

コメント

タイトルとURLをコピーしました