"out" keyword in async method has a different approach.
See the tutorial about async method:
https://live.gnome.org/Vala/Tutorial#Asynchronous_Methods

They is there an example that look similar to yours:
  async int fetch_webpage(string url, out string text) throws IOError {
     // Fetch a webpage asynchronously and when ready return the 
     // HTTP status code and put the page contents in 'text'
     [...]
     text = result;
     return status;
  }And how to use it, and handle the output:
  fetch_webpage.begin("http://www.example.com/";, (obj, res) => {
      try {
          string text;
          var status = fetch_webpage.end(res, out text);
          // Result of call is in 'text' and 'status' ...
      } catch (IOError e) {
          // Problem ...
      }
  });I think this example answers your question.
Tal

> Date: Tue, 14 Aug 2012 11:49:15 +0200
> From: ras...@rastersoft.com
> To: e...@yorba.org
> CC: vala-list@gnome.org
> Subject: Re: [Vala] Interfaces and asynchronous methods
> 
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Ok, here are the interesting pieces of the code:
> 
> interface backends : GLib.Object {
> [...]
>     public abstract async BACKUP_RETVAL start_backup(out int64
> last_backup_time);
> [...]
> }
> 
> private backends backend;
> var rv=this.backend.start_backup(out this.last_backup_time);
> 
> 
> BTW, Jim Nelson answered that I have to do something like this:
> 
> run_async.begin(on_run_async_completed);
> 
> /* ... */
> 
> void on_run_async(AsyncResult result, Object? source) {
>     int result = run_async.end(result);
> }
> 
> 
> Is this correct?
> 
> Thanks.
> 
> 
> El 14/08/12 01:10, Eric Gregory escribió:
> > On Mon, Aug 13, 2012 at 4:03 PM, rastersoft <ras...@rastersoft.com> wrote:
> >
> >>
> >> -----BEGIN PGP SIGNED MESSAGE-----
> >> Hash: SHA1
> >>
> >> Hi all:
> >>
> >> I tried to define an interface with an async method, but I receive this
> >> error in the line where I try to invoke it in an object that
> implements it:
> >>
> >> backup.vala:246.14-246.43: error: invocation of void method not allowed
> >> as expression
> >>
> >> Are async methods not allowed in interfaces?
> >>
> >> Thanks.
> >>
> >
> >
> > Could you paste the code that invokes the async method in this thread?
> >
> > - Eric
> >
> 
> - -- 
> Nos leemos
>                  RASTER    (Linux user #228804)
> ras...@rastersoft.com              http://www.rastersoft.com
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAlAqHxsACgkQXEZvyfy1ha+sKgCgxRoFUf2QmxrUQVH5B4n+z21y
> 6UIAnA4xXKunyl1qz/GajMhKNu4kGj9w
> =yxwF
> -----END PGP SIGNATURE-----
> 
> _______________________________________________
> vala-list mailing list
> vala-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/vala-list
                                          
_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to