M
Milwaukee Broad
Guest
I'm writing a C# WinForms app (VS 2017 Pro v15.7.4) and the app freezes when I try to run the code below:
private void btnAddVideo_Click(object sender, EventArgs e)
{
MessageBox.Show("Congratulations! You just clicked the Add Video button!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Add Video...";
ofd.Filter = "Video (*.avi, *.mpg, *.mpeg, *.wmv)|*.avi;*.mpg;*.mpeg;*.wmv";
if (DialogResult.OK == ofd.ShowDialog())
{
try
{
glbvidVideo = Video.FromFile(ofd.FileName);
clsMessage.bytVideo = File.ReadAllBytes(ofd.FileName);
if (glbvidVideo.Size.Height > glbvidVideo.Size.Width)
pbVideo.Size = pbVideo.MaximumSize = glbszPortraitSize;
else if (glbvidVideo.Size.Width > glbvidVideo.Size.Height)
pbVideo.Size = pbVideo.MaximumSize = glbszLandscapeSize;
glbvidVidewner = pbVideo;
btnRemoveVideo.Enabled = btnPlayVideo.Enabled = btnStopVideo.Enabled =
clsMessage.blMediaPresent = true;
clsMessage.strMediaType = "Video";
}
catch (Exception exVideoLoadError)
{
MessageBox.Show(exVideoLoadError.ToString(), "oops.", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
ofd.Dispose();
}
I've written this code many times in the past and it always ran without a hitch. The btnAddVideo click event handler has been set to run when the button is clicked and I should see the MessageBox generated by the first line of code, but I don't. Instead, the entire app just freezes and I have to close it by pressing the Stop button in Visual Studio. I'm at a loss as to how to fix it. Could there be something in the solution or Visual Studio that needs fixing?
Continue reading...
private void btnAddVideo_Click(object sender, EventArgs e)
{
MessageBox.Show("Congratulations! You just clicked the Add Video button!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Add Video...";
ofd.Filter = "Video (*.avi, *.mpg, *.mpeg, *.wmv)|*.avi;*.mpg;*.mpeg;*.wmv";
if (DialogResult.OK == ofd.ShowDialog())
{
try
{
glbvidVideo = Video.FromFile(ofd.FileName);
clsMessage.bytVideo = File.ReadAllBytes(ofd.FileName);
if (glbvidVideo.Size.Height > glbvidVideo.Size.Width)
pbVideo.Size = pbVideo.MaximumSize = glbszPortraitSize;
else if (glbvidVideo.Size.Width > glbvidVideo.Size.Height)
pbVideo.Size = pbVideo.MaximumSize = glbszLandscapeSize;
glbvidVidewner = pbVideo;
btnRemoveVideo.Enabled = btnPlayVideo.Enabled = btnStopVideo.Enabled =
clsMessage.blMediaPresent = true;
clsMessage.strMediaType = "Video";
}
catch (Exception exVideoLoadError)
{
MessageBox.Show(exVideoLoadError.ToString(), "oops.", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
ofd.Dispose();
}
I've written this code many times in the past and it always ran without a hitch. The btnAddVideo click event handler has been set to run when the button is clicked and I should see the MessageBox generated by the first line of code, but I don't. Instead, the entire app just freezes and I have to close it by pressing the Stop button in Visual Studio. I'm at a loss as to how to fix it. Could there be something in the solution or Visual Studio that needs fixing?
Continue reading...