Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Invalid Thread Access(Need to program in thread parallel to my RCP application)
Invalid Thread Access [message #525864] Thu, 08 April 2010 04:57 Go to next message
daitkarsachin  is currently offline daitkarsachin Friend
Messages: 8
Registered: April 2010
Junior Member
Hi all,
I have to run a program which will run in parallel to my RCP application. I used following statement in ApplicationWorkbenchWindowAdvisor class

....
public void preWindowOpen()
{
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
configurer.setInitialSize(new Point(400, 300));
configurer.setShowCoolBar(false);
configurer.setShowStatusLine(false);
configurer.setTitle("RCP Application");
Thread t=new Thread(new StreamConnection1(configurer.getWindow()));

But it gives invalid thread access exception. Later i modified this statement to
Desktop.getDefault(). asyncExec (new StreamConnection1(configurer.getWindow()));

but problem still persists.
please help me to solve this problem. I am sendinng IWindowWorkbench object as an parameter so that my parallel running process will update the view at runtime whenever some other process passes value to it.
Re: Invalid Thread Access [message #525867 is a reply to message #525864] Thu, 08 April 2010 05:49 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 08.04.2010 06:57, daitkarsachin wrote:
> Hi all,
> I have to run a program which will run in parallel to my RCP
> application. I used following statement in
> ApplicationWorkbenchWindowAdvisor class
>
> ...
> public void preWindowOpen() {
> IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
> configurer.setInitialSize(new Point(400, 300));
> configurer.setShowCoolBar(false);
> configurer.setShowStatusLine(false);
> configurer.setTitle("RCP Application");
> Thread t=new Thread(new StreamConnection1(configurer.getWindow()));

At this point it would help, if you say, *which* particular
operation fails.

> But it gives invalid thread access exception. Later i modified this
> statement to
> Desktop.getDefault(). asyncExec (new
> StreamConnection1(configurer.getWindow()));

Do you mean

Display.getDefault.asyncExec?

But again: This description does still not say, what kind of operation
is failing.

> but problem still persists. please help me to solve this problem. I am
> sendinng IWindowWorkbench object as an parameter so that my parallel
> running process will update the view at runtime whenever some other
> process passes value to it.

You are in the preOpen function. The docs say that the window's controls
have not been created, when this function is called:

"Performs arbitrary actions before the window is opened.

This method is called before the window's controls have been created.
Clients must not call this method directly (although super calls are
okay). The default implementation does nothing. Subclasses may override.
Typical clients will use the window configurer to tweak the workbench
window in an application-specific way; however, filling the window's
menu bar, tool bar, and status line must be done in
ActionBarAdvisor.fillActionBars, which is called immediately after this
method is called."

You didn't really say what you are trying to do in the UI thread,
but it looks as if you are trying to update a view, which cannot
exist at that point of time. What are you doing to access the view?
If you want to update a view, why don't you register such a
refresher in the init or createPartControl method of this particular
view?

Greetings from Bremen,

Daniel Krügler
Re: Invalid Thread Access [message #525869 is a reply to message #525867] Thu, 08 April 2010 06:06 Go to previous messageGo to next message
daitkarsachin  is currently offline daitkarsachin Friend
Messages: 8
Registered: April 2010
Junior Member
Thank you Daniel for ur valuable reply ,
I am building sample RCP application in which tableviewer displays some value comming from external server..I want to run a client for that server parallely to my RCP app.so that my view will get updated as soon as input comes from Server..

Also honestly i am not getting how RCP application flow runs thats why placed that statements in ApplicationWorkbenchWindowAdvisor..

I will be thankful if you shortly describe RCP applications flow.

Again thank you for your reply
Re: Invalid Thread Access [message #525893 is a reply to message #525869] Thu, 08 April 2010 08:14 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 08.04.2010 08:06, daitkarsachin wrote:
> Thank you Daniel for ur valuable reply ,
> I am building sample RCP application in which tableviewer displays some
> value comming from external server..I want to run a client for that
> server parallely to my RCP app.so that my view will get updated as soon
> as input comes from Server..
> Also honestly i am not getting how RCP application flow runs thats why
> placed that statements in ApplicationWorkbenchWindowAdvisor..

That still does not answer *what* you are doing here in your
WorkbenchWindowAdvisor. Are trying to open a view? It looks
like a bad idea to me that some external entity (like the advisor)
should do that, because views and editors are opened by the
RCP framework at some specific point in time. Again: Why does the
view not register itself for such a change observation? This is the
most reasonable strategy to me, because a not-yet-open view does
not need any refresh.

If this external control is absolutely necessary, you might want to
use IPartService (e.g. from IWorkbenchWindow#getPartService()) to
register a IPartListener or IPartListener2 to observe the life-cycle
of your particular view.

> I will be thankful if you shortly describe RCP applications flow.

You may consider the following articles:

http://www.eclipse.org/articles/Article-RCP-2/tutorial2.html
http://www.eclipse.org/articles/Article-UI-Workbench/workben ch.html

which provide excellent overviews.

HTH & Greetings from Bremen,

Daniel Krügler
Re: Invalid Thread Access [message #526202 is a reply to message #525893] Fri, 09 April 2010 08:38 Go to previous message
daitkarsachin  is currently offline daitkarsachin Friend
Messages: 8
Registered: April 2010
Junior Member
Daniel,
could you please tell me "how can we add a thread (which must able to update or refresh View ) to RCP application and where to put these thread related statements in our RCP application.
Previous Topic:Prevent loading a perspective
Next Topic:How do I find out the style of an SWT part?
Goto Forum:
  


Current Time: Tue Apr 23 15:42:29 GMT 2024

Powered by FUDForum. Page generated in 0.03550 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top