in reply to Re: Hrm
in thread using the send_im function in Net::OSCAR in Tk outside of a Net::OSCAR callback

I managed to get it to do what I wanted it to do without a GUI -- do_one_loop() doesn't do what I thought it did. It simply checks for waiting events and messages and acts accordingly. I took your advice and made a thread that sits and waits to send a message when activated by a shared variable. That did the trick. This should help me translate it into a GUI -- I'll look at the DoOneEvent function too, and see if I can do something with that. Thanks very much for your help and your patience with a perl newbie.

Replies are listed 'Best First'.
Re: Success!
by zentara (Cardinal) on Jun 28, 2006 at 11:15 UTC
    Great! I mentioned the DoOneEvent method, because in your code, it seemed that you needed to do a while(1){}, or run a second event loop. When you try to run 2 (or more) event-loop based programs, only 1 event loop can be in control, and you need to manually "pump" the othe loop(s) with DoOneEvent (or whatever their system calls it).

    In Tk the MainLoop is

    sub MainLoop unless ($inMainLoop) { local $inMainLoop = 1; while (Tk::MainWindow->Count) { DoOneEvent(0); } } }
    So if you can't use Tk::MainLoop in your program to be the controlling event loop, you can place the DoOneEvent in a timer, or a while(1) loop and effectively keep Tk active and responding.

    But it sounds like you are on your way with threads, and that is your best option.


    I'm not really a human, but I play one on earth. flash japh