⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 threadappui.cpp

📁 这是Symbian平台实现多线程的实例.对初学者非常有帮助.
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CThreadAppUi from CThreadAppUi.h
*  Part of  : Thread
*  Created  : 04.02.2005 by Forum Nokia
*  Version  : 1.0
*  Copyright: Nokia Corporation
* ============================================================================
*/

// INCLUDES
#include <avkon.hrh>
#include <aknnotewrappers.h> 

#include "Thread.pan"
#include "ThreadAppUi.h"
#include "ThreadAppView.h"
#include "Thread.hrh"
#include "ThreadEngine.h"

// ----------------------------------------------------------------------------
// CThreadAppUi::ConstructL()
//
// Standard EPOC 2nd phase constructor
// ----------------------------------------------------------------------------
void CThreadAppUi::ConstructL()
    {
    BaseConstructL(CAknAppUi::EAknEnableSkin);
    iAppView = CThreadAppView::NewL(ClientRect());
    iAppView->SetMopParent(this);
    // add view to control stack
    AddToStackL(iAppView);
	
    // create new watchdog for threads
    iThreadEngine = CThreadEngine::NewL(iAppView);
    }

// ----------------------------------------------------------------------------
// CThreadAppUi::CThreadAppUi()  
//
// constructor
// ----------------------------------------------------------------------------
CThreadAppUi::CThreadAppUi()                              
    {
    // No implementation required
    }

// ----------------------------------------------------------------------------
// CThreadAppUi::~CThreadAppUi()
//
// destructor
// ----------------------------------------------------------------------------
CThreadAppUi::~CThreadAppUi()
    {
    if ( iThreadEngine )
        {
        delete iThreadEngine;
        }

    if ( iAppView )
        {
        iEikonEnv->RemoveFromStack(iAppView);
        delete iAppView;
        }
    }

// ----------------------------------------------------------------------------
// CThreadAppUi::HandleCommandL(TInt aCommand)
//
// takes care of command handling
// ----------------------------------------------------------------------------
void CThreadAppUi::HandleCommandL(TInt aCommand)
    {
    switch(aCommand)
        {
        case EEikCmdExit:
        case EAknSoftkeyExit:
            Exit();
            break;

        case EThreadKillCommand1:
            {
            // kill thread1
            iThreadEngine->KillThread(1);
            }
            break;

        case EThreadKillCommand2:
            {
            // kill thread2
            iThreadEngine->KillThread(2);	
            }
            break;

        case EThreadKillCommand3:
            {
            // kill  thread3
            iThreadEngine->KillThread(3);
            }
            break;

        case EThreadStartCommand:
            {
            // start all threads
            iThreadEngine->StartL();
            }
            break;

        default:
            Panic(EThreadUi);
            break;
        }
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -