Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » Thread calls GUI
Thread calls GUI [message #20056] Sat, 14 February 2009 19:26 Go to previous message
Sami is currently offline  Sami
Messages: 6
Registered: July 2008
Promising Member
I realize a thread cannot call GUI in upp. It is not however clear how threading should be implemented then. I would ask help for proper solution to the example given below.

struct Interface {
  virtual int Ask ( const char * ) = 0;
};

struct Work {
  Interface *gui;
};

struct Library {
  Library ( Work w ) {
    int a = w.gui->Ask ( "Ok?" );
  }
};

void Threading ( Work w ) {
  Library ( w );
}

struct Task
:MyTask<TopWindow>
,Interface {
  typedef Task CLASSNAME;
  Task() {
    CtrlLayout(*this, "Example" );
    Work w;
    w.gui = this;
    Thread().Run ( callback1 ( Threading, w ) );
  }
  volatile Atomic q;
  int Ask_Weird_Hacked ( const char *s, unsigned dummy ) {
    return q = 1 + PromptYesNo ( String().Cat() << s );
  }
  int Ask ( const char *s ) {
    //problem here, cannot call PromptYesNo()
    q = 0;
    PostCallback ( callback2 ( this, &Task::Ask_Weird_Hacked, s, 0 ) );
    while ( !q ) Sleep ( 10 );
    return q - 1;
  }
};


So we begin with Task() and our problem is how to implement Ask() call properly. I first understood the Gate-method is what I'm looking for, but I didn't get it to work, can somebody explain what is it? The manual was in my opinion incomplete here.

[Updated on: Sun, 15 February 2009 00:14]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: StaticMutex/ONCELOCK question
Next Topic: GUI MT project does not compile
Goto Forum:
  


Current Time: Fri Apr 10 05:47:59 CEST 2020

Total time taken to generate the page: 0.01131 seconds