I keep getting an ObjectDisposedExpection when I need to get a Form to show.
Do you guys maybe know how to do this? In the foreach by NotitiesForm.Show() I get the error ObjectDisposedExpection. I am programming in Visual Studio Ultimate 2012 C#.
RichTextBox NotitiesTB = new RichTextBox();
private Form NotitiesForm;
/// <summary>
///
/// </summary>
/// <param name="label"></param>
///
public void NotitiesLatenZien()
{
if (filename != null)
{
BRTSignal signal = new BRTSignal(filename);
BRTEventRepository Notities = new BRTEventRepository(signal);
List<IBRTNote> note = Notities.ReadNotes();
BRTEventService TijdNotities = new BRTEventService(signal);
TijdNotities.MakeNoteTimesRelativeToTrack(note, 1);
//TextBox NotitiesTB = new TextBox();
//NotitiesTB.Name = "Notities";
if (NotitiesForm == null)
{
NotitiesForm = new Form();
}
NotitiesForm.Height = 600;
NotitiesForm.Width = 1000;
NotitiesForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
NotitiesForm.MaximizeBox = false;
NotitiesForm.Disposed +=NotitiesForm_Disposed;
NotitiesForm.Text = "Notities";
NotitiesTB.Multiline = true;
NotitiesTB.Height = 600;
NotitiesTB.Width = 980;
NotitiesTB.ReadOnly = true;
NotitiesTB.Clear();
//NotitiesTB.Click += NotitiesTB_Click;
//NotitiesTB.SelectionStart = Convert.ToInt32(referenceLineSelectedPage);
NotitiesTB.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Both;
NotitiesTB.Name = "Notities";
NotitiesForm.Controls.Add(NotitiesTB);
foreach (IBRTNote notes in Notities.ReadNotes())
{
//string test = Convert.ToString((notes.Time));
//textBox1.Text = String.Concat(textBox1.Text, string.Concat(Environment.NewLine, notes.Text));
if (NotitiesTB.Text == "")
{
NotitiesTB.Text += new BRTToDotNET.RTDateTime((long)notes.Time).ToDotNet().ToString() + " " + notes.Text;
}
else
{
NotitiesTB.Text += "\r\n" + new BRTToDotNET.RTDateTime((long)notes.Time).ToDotNet().ToString() + " " + notes.Text;
}
//MessageBox.Show("\r\n" + notes.Text);
NotitiesForm.Show();
NotitiesForm.BringToFront();
}
}
else
{
MessageBox.Show("Er blijkt een .sig file te missen. Controleer of u een .sig file heeft ingeladen.");
}
}
private void NotitiesForm_Disposed(object sender, EventArgs e)
{
NotitiesForm = null;
}
The code you posted seem "good enough". That is, you set the NotitiesForm variable when the object is disposed, and you create a new one if it's null. As long as all this code executes in the main UI thread, that part is fine.
But note that all controls in a Form are disposed of when the Form is disposed. So your NotitiesTB control will be disposed of the first time your NotitiesForm is closed. You then add that control to the next Form instance you create, and when it's shown, you get the exception because you're trying to show a Form containing a control that has already been disposed.
The right way to do this would be to design an actual Form subclass that already contains the RichTextBox instance you want. Then you don't have to keep adding a new instance to each new instance of the Form you create.
Barring that, then you need to create a new RichTextBox instance to go with each new Form instance you create, e.g. in the same place where you have the NotitiesForm = new Form(); statement.
Related
I have a simple desktop application which loads .cshtml view in a windows form. I build it and published on my remote machine for a specific folder on drive D. Everything works fine, if only 1 user from this machine runs the instance of this application on a target path. But if any other user try to run the same app, while the copy of that app is already running by another user it sees a blank form instead.
I've already covered the code with some logging and try{} catch{} blocks, but have no interesting info so far. The service which returns the desktop view runs at the same intranet and it returns the result all the time if you just go to URL against the browser.
What could be the problem and how can I find the true cause of its appearance?
I will be grateful for any advice.
Update 1: CoreWebView2InitializationCompleted contains an exception -> The requested resource is in use. (0x800700AA)
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.webView = new Microsoft.Web.WebView2.WinForms.WebView2();
((System.ComponentModel.ISupportInitialize)(this.webView)).BeginInit();
this.SuspendLayout();
//
// webView
//
this.webView.AllowExternalDrop = false;
this.webView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.webView.CreationProperties = null;
this.webView.DefaultBackgroundColor = System.Drawing.Color.White;
this.webView.Location = new System.Drawing.Point(10, 10);
this.webView.Name = "webView";
this.webView.Size = new System.Drawing.Size(690, 125);
this.webView.TabIndex = 0;
this.webView.ZoomFactor = 1D;
//
// MainForm
//
this.AccessibleDescription = "MessageBoard Wrapper";
this.AccessibleName = "MessageBoard Wrapper";
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(710, 145);
this.Controls.Add(this.webView);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MinimumSize = new System.Drawing.Size(250, 100);
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "MessageBoard Wrapper";
((System.ComponentModel.ISupportInitialize)(this.webView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private HttpClient GetClient()
{
var result = new HttpClient();
return result;
}
private Microsoft.Web.WebView2.WinForms.WebView2 webView;
private string _baseUrl = "here I have my service url";
public MainForm()
{
InitializeComponent();
FormBorderStyle = FormBorderStyle.None;
DoubleBuffered = true;
SetStyle(ControlStyles.ResizeRedraw, true);
var client = GetClient();
try
{
var targetmUrlForCustomBusinessLogic = "url address here";
var response = client.GetAsync(targetmUrlForCustomBusinessLogic).Result;
if (response.IsSuccessStatusCode)
{
var t = Task.Run(() => response.Content.ReadAsStringAsync()).Result;
//here I have some code too
}
}
catch (Exception ex)
{
var message = ex.Message;
//TODO: add logging here
}
finally
{
client.Dispose();
}
webView.Source = new Uri(_baseUrl);
webView.NavigationCompleted += WebView_NavigationCompleted;
ResizeEnd += (object sender, EventArgs e) => SaveFormSettings();
Move += (object sender, EventArgs e) => SaveFormSettings();
Shown += (object sender, EventArgs e) => LoadFormSettings();
}
I got this application to work in multi user mode by making the following changes.
I removed initialization of webView.Source property
I added a method which is preparing the environment for each user and explicitly trigger the initialization of webView control. (I'm calling this method inside of MainForm
private async Task InitAsync(string path) { var env = await Microsoft.Web.WebView2.Core.CoreWebView2Environment.CreateAsync(userDataFolder: path); await webView.EnsureCoreWebView2Async(env);
}
I set up path param for the user data folder in a next way
path = Path.Combine(Path.GetTempPath(), $"{Environment.UserName}");
I binded navigation path to the target URL in against CoreWebView2InitializationCompleted event handler.
private void webView_CoreWebView2InitializationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs e) { if (webView != null && webView.CoreWebView2 != null) { webView.CoreWebView2.Navigate(_baseUrl); } }
All the steps above solved my issus, which was occuring because each new instance of the app for a new user requred environment folder to deal with webView component. Hope that will save some time for somebody.
In C#.NET, I am trying to add controls from a static class to a non-static class.
This is my code:
public static void AddMediaToPanel(string Title, string Description, string Source, string Cover, string Genre, int Rating)
{
PictureBox MediaCanvas = new PictureBox();
MediaCanvas.BackColor = Color.LightGray;
MediaCanvas.BorderStyle = BorderStyle.FixedSingle;
MediaCanvas.Size = new Size(150, 235);
MediaCanvas.Padding = new Padding(10);
try
{
MediaCanvas.ImageLocation = Source;
}
catch { }
var gui = new GUI();
gui.Controls.Add(MediaCanvas);
}
The GUI method stands for a Windows Form called 'GUI'.
I'm trying to make an open-source media center that allows you to add movies
to a repository.
The static void AddMediaToPanel must be static, because of this class:
public static void RetrieveMedia(string XMLFile)
{
// Declare the Media Collections
MediaCollection media = null;
// Declare the XML-readers
XmlSerializer serializer = new XmlSerializer(typeof(MediaCollection));
StreamReader sr = new StreamReader(XMLFile);
try
{
media = (MediaCollection)serializer.Deserialize(sr);
}
catch(Exception ex)
{
MessageBox.Show("The following media repository could not be loaded:\n" +
XMLFile + "\n" +
"Please check your code and try again later.\n\n" +
"Error Information: " + ex.Message, "Repository error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
// Create new instance of the media class
sr.Close();
// Return properties
try
{
foreach (Video video in media.Video)
{
GUI.AddMediaToPanel(video.Title, video.Description, video.Source, video.Cover, video.Genre, video.Rating);
}
}
catch { }
}
I'm using .NET Framework 4.5.2.
Thanks in advance!
~ Kees van V.
This can't work this way. In your loop you are calling your static method:
foreach (Video video in media.Video)
{
GUI.AddMediaToPanel(video.Title, video.Description, video.Source, video.Cover, video.Genre, video.Rating);
}
But your static method creates a new Form each time, adds a control to it, then throw it away:
var gui = new GUI();
gui.Controls.Add(MediaCanvas);
You need to create your form once (outside of your static method), then have your static method return a control that you can add to your single Form instance.
Your instance method with the loop could look like:
var gui = new GUI();
foreach (Video video in media.Video)
{
var control = GUI.AddMediaToPanel(video.Title, video.Description, video.Source, video.Cover, video.Genre, video.Rating);
gui.Controls.Add(control);
}
In your current code you just create and throw away the gui form:
var gui = new GUI();
gui.Controls.Add(MediaCanvas);
You have to find the form instance you want the controls be added to:
public static GUI CurrentGui {
get {
GUI gui = Application
.OpenForms
.OfType<GUI>()
.LastOrDefault();
// no such form found, you may want to create the form
if (null == gui) {
gui = new GUI();
gui.Show(); // <- let's show it up
}
return gui;
}
}
...
public static void AddMediaToPanel(...) {
...
CurrentGui.Add(MediaCanvas);
}
I have program that displays a "Loading" Winform when a button is pressed and disappears once the script needing to be run is complete.
When the button is pressed, the new form 'appears' however it displays none of the form information, such as the Logo and labels - only a blank/grey box. I've attempted changing the background colour and altering images however it is still displaying as blank form.
What I find to be most confusing is that this blank form displayed only appears blank when a specific CS. file is called within the button press; PDFMerge.CombineMultiblePDFs. If I try to display the Loading form within a different part of the program, e.g. when a different button is pressed, the form loads correctly as planned with all content.
Here is the blank form being displayed:
Here is the correct form being displayed on a different button or different form
Here is the code I am calling which displays the "blank" Winform.
loadingPDF.Show(); // Show the loading form
string fileDate = DateTime.Now.ToString("dd-MM-yy");
string fileTime = DateTime.Now.ToString("HH.mm.ss");
string outcomeFolder = outputFolder;
string outputFile = "Combined Folder " + fileDate + " # " + fileTime + ".pdf";
string outputFileName = Path.Combine(outcomeFolder, outputFile);
// combines the file name, output path selected and the yes / no for pagebreaks.
PDFMerge.CombineMultiplePDFs(sourceFiles, outputFileName);
loadingPDF.Hide(); // Hide the loading form
If I replace the PDFMerge.Combine with a different within CS file, the Loading form displays correctly, which leads me to believe the issue is laying with the PDFMerge and when it is being called. Below is the code used within the PDFMerge;
public class PDFMerge
{
public static void CombineMultiplePDFs(String[] fileNames, string outFile)
{
try
{
int pageOffset = 0;
int f = 0;
Document document = null;
PdfCopy writer = null;
while (f < fileNames.Length)
{
// Create a reader for a certain document
PdfReader reader = new PdfReader(fileNames[f]);
reader.ConsolidateNamedDestinations();
// Retrieve the total number of pages
int n = reader.NumberOfPages;
pageOffset += n;
if (f == 0)
{
// Creation of a document-object
document = new Document(reader.GetPageSizeWithRotation(1));
// Create a writer that listens to the document
writer = new PdfCopy(document, new FileStream(outFile, FileMode.Create));
// Open the document
document.Open();
}
// Add content
for (int i = 0; i < n;)
{
++i;
if (writer != null)
{
PdfImportedPage page = writer.GetImportedPage(reader, i);
writer.AddPage(page);
}
}
PRAcroForm form = reader.AcroForm;
if (form != null && writer != null)
{
//writer.CopyAcroForm(reader);
writer.Close();
}
f++;
}
// Close the document
if (document != null)
{
document.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
I don't see what could be causing the clash with the form display, perhaps the Form isn't loading on time but i don't see how it works with some features and not with others. Any advice regarding the issue would be greatly appreciated. Thank you
Update 1:
Additional code requested,
Here is the code used to LoadingPDF form. I used Winforms to create the content on the form:
public partial class LoadingPDF : Form
{
public LoadingPDF()
{
InitializeComponent();
}
private void LoadingPDF_Load(object sender, EventArgs e)
{
//
}
}
Creating instance of the loadingPDF form in the file selection form
// Declaring the 'loading' form when files are being combined.
LoadingPDF loadingPDF = new LoadingPDF();
Building on the comments, the PDFMerge.CombineMultiplePDFs() is cpu-locking your program, causing the thread to stop loading the form before it finishes. You can adapt your code like this:
public void ShowLoading()
{
loadingPDF.Shown += loadingPDF_Shown;
loadingPDF.Show(); // Show the loading form
}
public void loadingPDF_Shown(object sender, eventargs e)
{
string fileDate = DateTime.Now.ToString("dd-MM-yy");
string fileTime = DateTime.Now.ToString("HH.mm.ss");
string outcomeFolder = outputFolder;
string outputFile = "Combined Folder " + fileDate + " # " + fileTime + ".pdf";
// combines the file name, output path selected and the yes / no for pagebreaks.
PDFMerge.CombineMultiplePDFs(sourceFiles, outputFileName);
loadingPDF.Hide(); // Hide the loading form
}
Shown is the last event to trigger when a form is loaded. This should load your images before you start your cpu-intensive process.
An alternative would be to put your cpu-intensive process on another thread, to keep the UI thread clear. You can do that like this:
public void ShowLoading()
{
loadingPDF.Show(); // Show the loading form
System.ComponentModel.BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += worker_DoWork;
worker.RunWorkerCompleted += worker_RunWorkerCompleted;
worker.RunWorkerAsync(); //Added missed line
}
void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//anything you want to do AFTER the cpu-intensive process is done
loadingPDF.Hide(); // Hide the loading form
}
public void worker_DoWork(object sender, DoWorkEventArgs e)
{
string fileDate = DateTime.Now.ToString("dd-MM-yy");
string fileTime = DateTime.Now.ToString("HH.mm.ss");
string outcomeFolder = outputFolder;
string outputFile = "Combined Folder " + fileDate + " # " + fileTime + ".pdf";
string outputFileName = Path.Combine(outcomeFolder, outputFile);
// combines the file name, output path selected and the yes / no for pagebreaks.
PDFMerge.CombineMultiplePDFs(sourceFiles, outputFileName);
}
Doing this with a background worker will keep your UI usable/clickable, and not make it freeze. Among other things, this allows for an animated loading form.
I have a button which when pressed closes the current form and opens a new form of the same class - i.e. so it opens a new form in it original state.
I have another button which has the same functionality, however I try to call a function in the code so when the new form opens it runs importGantt() a function of the form.
The problem I have is that when I click the button it closes the current form and opens a new one, as expected, however it does not call the importGantt() function until I close the application.
Any ideas?
Much appreciated.
private void browseFileToolStripMenuItem_Click(object sender, EventArgs e)
{
clearAndImport();
}
private void clearAndImport()
{
this.Hide();
Dashboard dashboard = new Dashboard();
dashboard.ShowDialog();
dashboard.importGantt();
this.Close();
}
private void importGantt()
{
// Edit Interface
btnImport.Visible = false;
dataCapPlan.Visible = true;
dataMilestones.Visible = true;
pnlGantt.Visible = true;
Graphics ganttGraphics = pnlGantt.CreateGraphics();
// Draw axis
// Import Files
fileCapPlan.Title = "Select Capital Plan File";
fileCapPlan.Filter = "Excel Workbook (.xlsx)|*.xlsx";
DialogResult resCapPlan = fileCapPlan.ShowDialog();
if (resCapPlan == DialogResult.OK)
{
cnStr = cnStr + fileCapPlan.FileName;
}
else
{
MessageBox.Show("Error: Unable to import file");
}
fileMilestones.Title = "Select Milestones File";
fileMilestones.Filter = "Excel Workbook (.xlsx)|*.xlsx";
DialogResult resMilestones = fileMilestones.ShowDialog();
if (resMilestones == DialogResult.OK)
{
cnStr2 = cnStr2 + fileMilestones.FileName;
}
else
{
MessageBox.Show("Error: Unable to import file");
}
// Use OleDb connection to import Excel data
using (OleDbConnection cn = new OleDbConnection(#"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + cnStr + ";Extended Properties=" + "'EXCEL 12.0 Xml;HDR=YES'"))
{
using (OleDbDataAdapter adapter = new OleDbDataAdapter(sqlSelectAll, cn))
{
adapter.Fill(dtCapPlan);
dataCapPlan.DataSource = dtCapPlan;
dataCapPlan.AutoResizeColumns();
}
}
using (OleDbConnection cn = new OleDbConnection(#"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + cnStr2 + ";Extended Properties=" + "'EXCEL 12.0 Xml;HDR=YES'"))
{
using (OleDbDataAdapter adapter = new OleDbDataAdapter(sqlSelectAll, cn))
{
adapter.Fill(dtMilestones);
dataMilestones.DataSource = dtMilestones;
dataMilestones.AutoResizeColumns();
}
}
// Draw Gantt Chart
foreach (DataRow rowCapPlan in dtCapPlan.Rows)
{
id = rowCapPlan["Program ID"].ToString();
foreach (DataRow rowMilestone in dtMilestones.Rows)
{
if (id == rowMilestone["Program ID"].ToString())
{
// calculate space in days from todays date and the milestone date
msDate = Convert.ToDateTime(rowMilestone["Milestone Date"]);
msTimespan = msDate - calDate;
msIntDate = (int)msTimespan.TotalDays + 1;
tTimespan = tDate - calDate;
tIntDate = (int)tTimespan.TotalDays + 1;
ganttPlotSpace = msIntDate - tIntDate;
// Draw each milestone or gateway which is not yet complete
if (rowMilestone["% Complete"].ToString() != "100")
{
taskname = rowMilestone["Task Name"].ToString();
if (taskname == "Gateway 1" || taskname == "Gateway 2" || taskname == "Gateway 3" || taskname == "Gateway 4" || taskname == "Gateway 5")
{
Rectangle gw = new Rectangle(startx + ganttPlotSpace, starty - 4, 2, 11);
ganttGraphics.DrawRectangle(gwPen, gw);
ganttGraphics.FillRectangle(gwBrush, gw);
}
else
{
Rectangle ms = new Rectangle(startx + ganttPlotSpace + 1, starty, 2, 2);
ganttGraphics.DrawRectangle(msPen, ms);
ganttGraphics.FillRectangle(msBrush, ms);
}
ganttGraphics.DrawLine(linePen, startx - 10, starty - 11, pnlGantt.Right, starty - 11);
}
}
}
starty = starty + 22;
}
ganttGraphics.DrawLine(linePen, startx - 10, starty + 11, pnlGantt.Right, starty + 11);
}
image with gantt
image after clearAndImport method (FIXED by user)
As per Brij guidance:
Okay, so with the guidance this almost works, the code is now as follows...
This now opens the new form and runs the import method, however, it seems to be running it on a loop. I.e. it runs successfully displaying the gantt, but then tries to run the import gantt method again.
bool clear;
public Dashboard(bool clear = false)
{
InitializeComponent();
dataCapPlan.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(dataCapPlan_ColumnHeaderMouseClick);
this.clear = clear;
this.Load += new EventHandler(Dashboard_Load);
}
private void Dashboard_Load(object sender, EventArgs e)
{
if (this.clear)
{
this.importGantt();
}
}
// Clear and import method
private void clearAndImport()
{
this.Hide();
Dashboard dashboard = new Dashboard();
dashboard.clear = true;
dashboard.ShowDialog();
this.Close();
}
I think the method that you are referring is below:
private void clearAndImport()
{
this.Hide();
Dashboard dashboard = new Dashboard();
dashboard.ShowDialog();
dashboard.importGantt();
this.Close();
}
You are calling dashboard.ShowDialog(). So until you close the "Dashboard" form, next line of code (dashboard.importGantt()) won't get called. I suggest you call importGantt() in constructor or Load event of Dashboard form. You could change the sequence of code as well by moving dashboard.importGantt() above dashboard.ShowDialog().
As per your comment, I suggest, modify the constructor of Dashboard class to accept a boolean parameter and make it optional (defaulting to false). If true is passed, then only call importGantt(). So it will be like:
public Dashboard(bool clear = false)
{
InitializeComponent();
if(clear)
{
this.importGantt();
}
}
and the you clearAndImport() method will be like:
private void clearAndImport()
{
this.Hide();
Dashboard dashboard = new Dashboard(true);
dashboard.ShowDialog();
this.Close();
}
As per my last comment, try this:
bool clear = false;
public Dashboard(bool clear = false)
{
InitializeComponent();
this.clear = clear;
this.Load += new EventHandler(Dashboard_Load);
}
void Dashboard_Load(object sender, EventArgs)
{
if(this.clear)
{
this.importGantt();
}
}
Try dashboard.Show(); instead of dashboard.ShowDialog();
using (var dashboard = new Dashboard())
{
dashboard.Show(); // Show the form
dashboard.importGantt(); // Call
dashboard.Close(); // Close it when you're done...
}
I am here due to a strange behaviour in Button_Click event. The code is attached.
The issue is the first StripStatus message is never displayed. any ideas as to why?
private void FireBtn_Click(object sender, EventArgs e)
{
// Control local controls for launching attack
AwayTableLayoutPanel.Enabled = false;
AwayCancelBtn.Enabled = false;
FireBtn.Enabled = false;
////////////// Below statusBar message is never displayed but the folowing sound clip is.
GameToolStripStatusLabel.Text = "(Home vs. Away)(Attack Coordinate: (" +
GameModel.alphaCoords(GridLock.Column) + "," + GridLock.Row + "))(Action: Fire)";
////////////////////////////////////////////
if (audio)
{
SoundPlayer fire = new SoundPlayer(Properties.Resources.fire);
fire.PlaySync();
fire.Dispose();
}
// compile attack message
XmlSerializer s;
StringWriter w;
FireGridUnit fireGridUnit = new FireGridUnit();
fireGridUnit.FireGridLocation = GridLock;
s = new XmlSerializer(typeof(FireGridUnit));
w = new StringWriter();
s.Serialize(w, fireGridUnit);
//////////////////////////////////////////////////////////
// send attack message
GameMessage GameMessageAction = new GameMessage();
GameMessageAction.gameAction = GameMessage.GameAction.FireAttack;
GameMessageAction.statusMessage = w.ToString();
s = new XmlSerializer(typeof(GameMessage));
w = new StringWriter();
s.Serialize(w, GameMessageAction);
SendGameMsg(w.ToString());
GameToolStripStatusLabel.Text = "(Home vs. Away)(Attack Coordinate: (" +
GameModel.alphaCoords(GridLock.Column) + "," + GridLock.Row + "))(Action: Awaiting Fire Result)";
}
EDIT: if I put in a messageBox after the StripStatus message the status is updated.
There's a lot of stuff going on after you assigned the Text property. The label will not visually update until the Click event handler is done executing. It's Paint event cannot run until the UI thread goes idle again.
You can force it to paint right away by calling the strip's Update() method:
GameToolStripStatusLabel.Text = "...";
GameToolStrip.Update();