Re: Using gtk_timeout_add with very short timeperiods (45 ms)



I am not quite sure about what your problem is, maybe you need to send some
codes.
But you maybe want to check:
1.  the function that you made for the time out call back, whether you set the
return value to 0.
    You must set the return value to 1 so that the call back function will be
called again and again.  If the
     return value is 0, it will be only called once.

The gtk timeout function is based on signal, so that it won't block any thing.
It works like in the gtk main loop, every 45ms, it will send out a signal and
call your callback function.
Because it won't block any thing, of course you still can resize window any
time.

If you want to block the process, you better use the thread stuffs or simply
call usleep(...).

Jiang

Erik Forsberg wrote:

> I'm trying to write a program that reads a hardware port every 45 ms,
> it's a CID application with a piece of hardware attached to the
> parallell port.
>
> I tried having a gtk_timeout_add that runs a function every 45 ms, but
> it doesn't seem to work very well. The Clist I have in the program
> doesn't get updated and the same goes for most of the program. You can
> still resize the window.
>
> Could this be because of the short time period between the calls? It
> might be so that my function takes more than 45 ms, but I don't think
> so. I guess I could measure that.
>
> I guess another solution is to have a separate thread blocking on the
> hardware. However, I'm still interested in the answer to the question above.
>
> \EF
> --
> Erik Forsberg                 http://www.lysator.liu.se/~forsberg/
> PGP fingerprint = 37 1B D7 9E 97 8C EF 39  0E DE 08 E8 99 0C 5E A9
>
> _______________________________________________
> gtk-list mailing list
> gtk-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-list





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