I have a game program in C # that I am developing. It uses sound samples and winsock.
When I test the launch of the game, most of the sound works fine, but from time to time, if several samples are played, the application form is shaken a little, and then returns to its previous position.
How can I debug this or present it to you in a controlled manner? I am sure that no one will want all the application code to be afraid of virus attacks.
please help me..
EDIT: I was not able to commit any section of code that produces this result. he just does, and I can’t explain it.
EDIT: no position x / y does not change. the window seems to swing around a few pixels, and then returns to the position if it were before shaking.
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 code above to make this shiver?
EDIT: yes, the code runs within: this.Invoke (new action (delegate () {....})); could it be? how to solve it?
EDIT:
stream = Properties.Resources.ResourceManager.GetStream("_destroyed");
player = new System.Media.SoundPlayer(stream);
player.PlaySync();
player.Dispose();
stream.Dispose();
if you take out the above code, then it works great! any ideas?
EDIT: I replaced the line:
stream = Properties.Resources.ResourceManager.GetStream("_destroyed");
for a different file name, but the problem still exists, but at least the audio file is not corrupted.
EDIT: MSN, when does someone send a push? it looks a bit like this, but only happens 2 or 3 times.
EDIT: Do you use any third-party libraries? - No, I do not use any third-party libraries.
EDIT: It seems that no matter which file, the third sample always calls this.
EDIT: , . 3 , .
EDIT: @nobugz: , , . . , , .
EDIT: , Application.DoEvents(); . :)
EDIT: . , . QueueUserWorkItem. , , .. , .
, .