Solved

Base Priority

Posted on 2003-11-08
6
313 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

864 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now