Hi,
I know and understand the cause of this error but I am curious why there are no convenience methods. For example on Windows Mobile platform, and .NET UI in general, I would do this.
The convenience property 'InvokeRequired' is really nice because it hides details of the mechanism. One could be oblivious and still be successful as long they stuck to the rules. Also, if the rules of when to call BeginInvoke()/Invoke() were to change internally once would safe.Code:public void someFoobarMethod() { if (InvokeRequired) { BeginInvoke(new Action(() => tinkerWithUI())); } else { tinkerWithUI(); } }
However, in eSWT, and SWT in general I assume, I do this;
Note the line if (Thread.currentThread() != display.getThread()) in the code above this is very implementation specific and potentially could break in future. The mechanism is exposed and in my opinion this is a bad thing. I like 'InvokeRequired()' because it hides actually implementation and one doesn't really have to understand what is going on. Is there a reason there is no convenience method? I am curious that's all. I am thinking there must be some smart reason why none is provided and I want to understand it.Code:public void someFoobarMethod() { if (Thread.currentThread() != display.getThread()) { display.asyncExec(new Runnable() { public void run() { tinkerWithUI(); } }); } else { tinkerWithUI(); } }
Thanks!

Reply With Quote


