Solved

Base Priority

Posted on 2003-11-08
6
322 Views
Last Modified: 2013-11-20
Hi

How do I change my app's default Base Priority from the default 8 to a higher value.
I done the following but it had no effect

  HANDLE hProc = GetCurrentThread();
  SetThreadPriority(THREAD_PRIORITY_HIGHEST);


0
Comment
Question by:Dj_Fx8
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 9707575
SetPriorityClass(GetCurrentProcess(), ...);

All threads in the process get this priority. SetThreadPriority changes relative priority from the value set by SetPriorityClass.
0
 

Author Comment

by:Dj_Fx8
ID: 9742613
Hi Alex
Sorry for the delay I thought I had posted this a few days ago. I tried what you said but it had no effect I put the code in CMyApp::InitInstance, should it be somewhere else
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 9745636
Yes, it should be in InitInstance. Please show your code, this should work.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Dj_Fx8
ID: 9758496
Hi Alex
Here the whole InitInstance

// CDjMM8App initialization

BOOL CDjMM8App::InitInstance()
{
      AfxEnableControlContainer();

      // Standard initialization
      // If you are not using these features and wish to reduce the size
      //  of your final executable, you should remove from the following
      //  the specific initialization routines you do not need.
/*      if(!AfxOleInit())
      {
            AfxMessageBox(_T("Ole Initialization failed"));
            return FALSE;
      }*/

      AfxGetModuleState()->m_dwVersion = 0x0601;

#ifdef _AFXDLL
      Enable3dControls();                  // Call this when using MFC in a shared DLL
#else
      Enable3dControlsStatic();      // Call this when linking to MFC statically
#endif

//      HANDLE hProc = GetCurrentThread();
      
///******H E R E   I S    Y O U R    C O D E
      SetPriorityClass(GetCurrentProcess(),16);

      // Set Registry Key
      SetRegistryKey(_T("KaS Software"));

      LoadStdProfileSettings();  // Load standard INI file options (including MRU)

      //** create the font I want to use throught the app
      m_ghFontTahoma90 = new CFont;
      VERIFY(m_ghFontTahoma90->CreatePointFont(90, _T("Tahoma")));

      //** Create the coloured brushes
      g_pbrWheat = new CBrush;
      g_pbrWheat->CreateSolidBrush(RGB(255,209,204));
      g_pbrTomatoe = new CBrush;
      g_pbrTomatoe->CreateSolidBrush(RGB(255,99,71));
      g_pbrPage = new CBrush;
      g_pbrPage->CreateSolidBrush(RGB(255,228,210));
      g_pbrBlack = new CBrush;
      g_pbrBlack->CreateSolidBrush(RGB(0,0,0));
      g_pbrRed = new CBrush;
      g_pbrRed->CreateSolidBrush(RGB(255,0,0));
      g_pbrGreen = new CBrush;
      g_pbrGreen->CreateSolidBrush(RGB(0,255,0));
      g_pbrYellow = new CBrush;
      g_pbrYellow->CreateSolidBrush(RGB(250,240,30));


      // Register the application's document templates.  Document templates
      //  serve as the connection between documents, frame windows and views.
      CSingleDocTemplate* pDocTemplate;
      pDocTemplate = new CSingleDocTemplate(
            IDR_MAINFRAME,
            RUNTIME_CLASS(CDjMM8Doc),
            RUNTIME_CLASS(CMainFrame),       // main SDI frame window
      RUNTIME_CLASS(CDjMM8View));
      AddDocTemplate(pDocTemplate);

      // Parse command line for standard shell commands, DDE, file open
      CCommandLineInfo cmdInfo;
      ParseCommandLine(cmdInfo);

      // Dispatch commands specified on the command line
      if (!ProcessShellCommand(cmdInfo))
            return FALSE;

      // The one and only window has been initialized, so show and update it.
      m_pMainWnd->ShowWindow(SW_SHOW);
      m_pMainWnd->UpdateWindow();


      //Initalise BASS
      if (!BASS_Init(1,44100,0,0,NULL)){
            CString szTemp;
            szTemp.Format("%d",BASS_ErrorGetCode());
            AfxMessageBox("The Audio Engine could not be initialised.\nIf the problem persists restart the computer\nError Code:" + szTemp + "\nBas Init", MB_ICONSTOP | MB_OK);
            AfxGetMainWnd()->PostMessage(WM_CLOSE);
      }
      BASS_Start();


      return TRUE;
}
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 250 total points
ID: 9758563
You can use the following constants with SetPriorityClass:

ABOVE_NORMAL_PRIORITY_CLASS       0x00008000
BELOW_NORMAL_PRIORITY_CLASS       0x00004000
HIGH_PRIORITY_CLASS                         0x00000080
IDLE_PRIORITY_CLASS                          0x00000040
REALTIME_PRIORITY_CLASS                 0x00000100

Read their description in MSDN topic SetPriorityClass and select one of them. Don't use hard-coded values.
You can check this code in the Task Manager. Right-click the process and select Set Priority. Current process priority is checked.
0
 

Author Comment

by:Dj_Fx8
ID: 9759953
Hi Alex
That got it sorted many thanks

Steven
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question