The idea is quite simple. The drawback of this technique is that I cannot directly call the Text property of ToolStripStatusLabel and so this property remains unsafe. However, this solution works. The second solution satisfies me better. I override the Text property of ToolStripStatusLabel and make it totally safe so that it is no longer possible to call the original Text property. I think this solution is more elegant and it can be used with other ToolStrip items of a StatusStrip.
The code of this solution is given below. However, it appears ToolStripStatusLabels do not inherit from control, so they have no. Invoke, or. So how would I thread-safe make a call to change it's text property? This is because the ToolStrip manually handles the drawing of its component bits, much the same way that WPF manages the drawing of all of its component bits, without generating a separate handle for each one.
This is useful because it's easy to forget that every Control has an associated HANDLE and the system only has a finite number of those to dish out, e. I've run into this before also. I mentioned it in a sidebar on another question , for example. I should update that text to reflect my more recent understanding. Also, in general, you do not Have to use the InvokeRequired and BeginInvoke on the exact same control that you are manipulating in code, as long as you can guarantee that the control you are manipulating was created on the same thread e.
You can do this by using the delegate key word and the Control. Invoke method. This example shows how you manage a thread safe. Text and. ForeColor ajustment. BeginInvoke or Invoke method and place the Status strip items inside it. Windows Forms Screenshot. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow.
Learn more. Ask Question. Asked 12 years, 6 months ago. Here is the code I wrote in C. When a new string is assigned to a. Windows Server Developer Center. Sign in. United States English. Home Learn Downloads Community. Ask a question.
Quick access. Search related threads. Remove From My Forums. Answered by:. Archived Forums V.
0コメント