0

I'm creating a Windows Forms program and in VS2017/2019, the intellisense doesn't prompt InvokeRequired property for no matter TextBox control or the form itself.

When compiling, the error:'InvokeRequired' is not a member of Textbox was generated by compiler.

When navigate in Object Browser, Control class has the InvokeRequired property defined and TextBoxBase inherits Control, then TextBox inherits TextBoxBase. So TextBox supposed to have this property.

Does anyone has a clue on this issue?

  • The `Textbox` object is not a `Windows.Forms.Control`, then. Btw, the Objects declaration and the (code + context) that can reproduce the problem are missing. – Jimi Dec 29 '19 at 07:52
  • Btw2: you don't need `InvokeRequired`. `BeginInvoke` the Container Form or use the current `SynchronizationContext` (the latter is probably a better solution, all considered - the future, too). Btw3: Visual Studio 2017 or 2019? Are you using both, at the same time, same project? – Jimi Dec 29 '19 at 08:01
  • For a simple case, if I try to update the textbox's content in non-UI thread, an exception will raised by runtime forbidding me modify UI element, thant's why InvokeRequired is neccsary. And since TextBox class inherits Control, even if I cast the TextBox object to Control class, the InvokeRequired property is not shown neither. That's the strange part. – Alex Xinrun Du Dec 30 '19 at 08:16
  • InvokeRequired is **not** required. It's a thread-safe way to check whether the current code is executing in a thread other than the UI thread. You don't need it because you can simply `BeginInvoke()` the UI thread (from another thread or from the UI thread itself). If your TextBox doesn't expose a Control-derived property, then the `TextBox` object doesn't derive from Control. You didn't post any code related to the *problem* or code that can reproduce it, so nobody knows what you're actually doing. – Jimi Dec 30 '19 at 08:28

0 Answers0