g_spawn_async in win32

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have a gtk program doing now and then a calculation taking a few secs.
To prevent freezing my appl. I want to use for Linux g_thread.
However, this is not supported for Windows in combination  with gtk.
As far as I know the only possibility to solve this for Windows is using
an external program and call this by g_spawn_async. (Not a nice method; is
there another way?)

As far as I know g_spawn_async should work under Windows, but I can't get
it to work.

Below a test program; it works fine under Linux, but g_spawn_async returns
always FALSE under Windows.
(In this example g_spawn_async opens nedit. Note that the (now commented
out) 'system' call does work.)
(glib version is 2.16.3.)

#include "gtk/gtk.h"

static void post_process(GPid pid,int status,gpointer data)
{
  // ext. program did end
  puts("post_process");
}

main(int argc,char **argv)
{
  char *sargv[2];
  GPid pid=0;
  gtk_init(&argc,&argv);

  sargv[0]="nedit";
  sargv[1]=NULL;
//system(sargv[0]);
  if (g_spawn_async(NULL,sargv,NULL,
                    G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
                    NULL,
                    NULL,&pid,NULL))
  {
    g_child_watch_add(pid,(GChildWatchFunc)post_process,NULL);
    gtk_main();
  }
  else
  {
    puts("ERROR!");
  }

}


_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux