Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

timeBeginPeriod (winmm)
 
.
Summary
The timeBeginPeriod function sets the minimum timer resolution for an application or device driver. Used to manipulate the timer frequency.

C# Signature:

[DllImport("winmm.dll", EntryPoint="timeBeginPeriod")]
public static extern uint MM_BeginPeriod(uint uMilliseconds);

VB Signature:

Declare Function timeBeginPeriod Lib "winmm.dll" (ByVal uPeriod As Integer) As Integer

User-Defined Types:

None.

Notes:

Also see TimeGetTime (MM_GetTime) and TimeEndPeriod (MM_EndPeriod)

Tips & Tricks:

Please add some!

Sample Code:

static void Main(string[] args)
{
  StreamWriter oWriter = null;
  MM_BeginPeriod(1); // set timer resolution to 1ms => freq=1000Hz

  try
  {
    oWriter = new StreamWriter(@"ticks.txt");
    // tickcount has resolution of 16.5ms, mmtime has 1ms
    for(int nLoop = 0; nLoop < 100000; nLoop++)
      oWriter.WriteLine("{0}: TickCount={1}, MMTime={2}", nLoop, Environment.TickCount, MM_GetTime());
  }
  catch(IOException oException)
  {
    Console.WriteLine(oException.Message);
  }
  finally
  {
    if(oWriter != null)
      oWriter.Close();
  }

  MM_EndPeriod(1);
}

Alternative Managed API:

Do you know one? Please contribute it!

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions