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

  • Home
  • SEARCH
  • 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 710555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:38:02+00:00 2026-05-14T04:38:02+00:00

I have a C# game program that i’m developing. it uses sound samples and

  • 0

I have a C# game program that i’m developing. it uses sound samples and winsock.

when i test run the game most of the audio works fine but from time to time if it is multiple samples being played sequentially the application form shakes a little bit and then goes back to its old position.

how do i go about debugging this or present it to you folks in a manageable manner? i’m sure no one is going to want the whole app code in fear of virus attacks.

please guide me..

EDIT: i have not been able to pin down any code section that produces this result. it just does and i cannot explain it.

EDIT: no the x/y position are not changing. the window like shakes around a few pixels and then goes back to the position were it was before the shake.

if (audio)
{
    Stream stream;
    SoundPlayer player;

    stream = Properties.Resources.ResourceManager.GetStream("_home");
    player = new System.Media.SoundPlayer(stream);
    player.PlaySync();
    player.Dispose();

    string ShipID = fireResult.DestroyedShipType.ToString();
    stream = Properties.Resources.ResourceManager.GetStream("_" + ShipID);
    player = new System.Media.SoundPlayer(stream);
    player.PlaySync();
    player.Dispose();

    stream = Properties.Resources.ResourceManager.GetStream("_destroyed");
    player = new System.Media.SoundPlayer(stream);
    player.PlaySync();
    player.Dispose();
}

can you see anything in the above code that would produce this shake?

EDIT: yes the code is being executed within a: this.Invoke(new Action(delegate(){ ….})); could this be it? how do i resolve this?

EDIT:

           stream = Properties.Resources.ResourceManager.GetStream("_destroyed");
           player = new System.Media.SoundPlayer(stream);
           player.PlaySync();
           player.Dispose();
           stream.Dispose();

if the take out the above code, then it works fine! any ideas?

EDIT: i replaced the line with:

stream = Properties.Resources.ResourceManager.GetStream("_destroyed");

to a different file name but the problem is still there but at least it is not the audio file is corrupt.

EDIT: MSN when someone sends a nudge? it is bit like that but only happens 2 or 3 times.

EDIT: Are you using any 3rd party libraries? – no i am not using any 3rd party libs.

EDIT: it seems no matter what file, the 3rd sample always causes this.

EDIT: happens everywhere i use sound samples. if i play 3 samples, the situation happens.

EDIT: @nobugz: yes think you are right. the problem is holding up the UI thread for too long. as i have tried just using a merged audio file and the problem is there given its original duration.

EDIT: i solved this issue by putting Application.DoEvents(); after each sample play command. no shakes 🙂

EDIT: the above solution did not really work. as the number of player samples grew the application GUI got stuck again. a solution using QueueUserWorkItem has been employed instead. this still remains to be proven as a satisfactory solution as cross therading occurs i.e. a new thread of samples can be started while an old one is still playing.

will update this as more knowledge comes to light.

  • 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-05-14T04:38:03+00:00Added an answer on May 14, 2026 at 4:38 am

    Calling PlaySync on the UI thread isn’t so great. It will make your main window unresponsive as your UI thread is busy waiting for the sound to finish, it doesn’t get around to pumping messages like it should do. If that takes long enough, Windows steps in and overlaps the window with a “ghost”, it usually says “Not Responding” in the title bar (if it has one). This ghost window might not quite match your own window, that could explain the “shaking”.

    Using Play() instead will solve that problem. But gets you a new one, sequencing sounds becomes difficult. Making the calls from a thread can solve both. Check out NAudio for better control over sound.

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

Sidebar

Ask A Question

Stats

  • Questions 376k
  • Answers 376k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I found this lovely piece of software: ie-css3.js CSS3 pseudo-class… May 14, 2026 at 8:33 pm
  • Editorial Team
    Editorial Team added an answer Good question. It's not possible using the border property. The… May 14, 2026 at 8:33 pm
  • Editorial Team
    Editorial Team added an answer See http://bugs.php.net/bug.php?id=33060 - this is what's causing your issue. You… May 14, 2026 at 8:33 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.