C ++ application portal

Source: Internet
Author: User

C ++ application portal

Maybe you are a little confused about the entrance to designing an application. Here are some simple routines.
// You write an app class on your own and inherit from a Thread class. Of course, you can encapsulate this thread class on your own, or you can find the open-source class MyApp: XxThread {public: bool NeedStop (); void NoticeStop ()} void Run (){
While (1) {if (m_bNeedStop) {break ;}} private: bool m_bNeedStop;} // it is best to call this function in the main thread, because this ensures that because of the existence of while, the main thread will not exit immediately. // if it is not called in the main thread, there must be another mechanism to ensure that the main thread will wait until the sub-thread stops running and then exit to start the APP, in two cases, one is in the command line program // if it is called in main, it must be joined, the main thread can exit int main (int argc, char ** argv) {MyApp: GetInstance ()-> Start (); MyApp: GetInstance () earlier than the sub-thread () -> Join ();} another type is in MFC. For example, in a button clicking event, you can directly call MyApp: GetInstance ()-> Start (). This time, no need to join, because unless you close the MFC program, it will not exit void CTxServerWinDlg: OnBnClickedButton1 () {MyApp: GetInstance () -> Start ();}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.