Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8186277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:08:26+00:00 2026-06-07T02:08:26+00:00

This is a Visual Studio Express C++ Windows Forms application. I want to play

  • 0

This is a Visual Studio Express C++ Windows Forms application.

I want to play a WAV file strFileName.WAV in a WAV play wavPlayer every 10 seconds from the time I press the “Start” button until such time as I press the “Stop” button.

When each 10 second interval is up, TimerEventProcessor plays the WAV file.

The problem is that I have to press “Stop” twice to get it to work. The first press of “Stop” seems to be ignored.

Why is btnStop_Click not executing the first time I press “Stop”?

private: System::Void bntStart_Click(System::Object^  sender, System::EventArgs^  e) {
  if (String::IsNullOrEmpty(strFileName)) {
    lblRunning->Text = L"Cannot Start Until File Is Loaded";
  }
  else {
    lblRunning->Text = L"Running";   
    myTimer->Interval = iIntervalSeconds * 1000;
    myTimer->Tick += gcnew EventHandler( TimerEventProcessor );
    myTimer->Enabled = true;
    while (lblRunning->Text == L"Running") {
      Application::DoEvents();
    }
  }
}

private: System::Void btnStop_Click(System::Object^  sender, System::EventArgs^  e) {
  lblRunning->Text = L"Stopped";
  myTimer->Enabled = false;
  wavPlayer->Stop();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T02:08:27+00:00Added an answer on June 7, 2026 at 2:08 am

    Get rid of the

    while (lblRunning->Text == L"Running") {
      Application::DoEvents();
    }
    

    loop. When you return from bntStart_Click the form will return to dispatching messages and the timer will tick as expected. There is no need for you to create a manual Application::DoEvents() loop, which is probably the cause of your problem.

    By calling Application::DoEvents(); in a loop you are creating a pooling loop for window messages. Without any sleep call this loop cause 100% CPU usage. By letting your bntStart_Click return the WinForms runtime will sleep your process until a message is ready – resulting in very low CPU usage.

    This high CPU usage is probably making your application unresponsive which is why it seems that clicks are not being processed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an application ( C# , Windows Forms ) on Visual Studio 2008 ,
This code compiled properly on Visual Studio 2010 on Windows, but I'm getting this
I downloaded the Microsoft Visual Studio 2010 Express for Windows Phone and I wrote
Taken from Exercise 1: Creating Windows Phone Applications with Microsoft Visual Studio 2010 Express
I want to create a windows installer package using visual studio. It is my
I have Visual Studio 11 Beta (Express for Windows 8) installed in my Windows
My Visual Studio .NET application uses SQL Server 2005 Express. It has to be
A C# desktop application (on the Visual Studio Express edition) worked, but then it
Windows XP Pro 32bit Visual studio 2008 VC Express edition. I have installed cmake
I'm using c++/cli with visual studio 2010 express edition. What I want to do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.