Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Base Priority

Posted on 2003-11-08
6
Medium Priority
?
337 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 1000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

610 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