(I didn't notice that you cross-posted to comm-dev-forum. If I had, I would
have answered there, but I'll continue here...)

"Adrian Pfisterer" <[EMAIL PROTECTED]> wrote in message
news:54327@palm-dev-forum...
> I can't simply make my WriteProc loop internally until it is done
> because my output is the IR library which uses a callback to let
> me know when I can write the next chunk.

I haven't used ExgDBWrite with the IR Library (an unusual combination), but
I have two ideas for how to do this.

1) Buffer the data in a FileStream. Have the WriteProc write the data to a
FileStream and then send it out via the IR Library when it's done. This will
obviously work, but it requires a bunch of space in the storage heap.

2) Create a blocking API for your IR Library transport. You have your own
little event loop that runs while you're waiting for a callback from the IR
Library. The following snippets are from an app that uses this approach,
along with a progress dialog.

static EventType ProcessOneEvent(void)
{
    EventType event;
    UInt32 delay;

    delay = TimeUntilNextAction();
    EvtGetEvent(&event, delay);
    PrgHandleEvent(ProgressP, &event);
        // will call SysHandleEvent, MenuHandleEvent, and FrmHandleEvent as
necessary
    if (PrgUserCancel(ProgressP) && !UserCancelled)
        CancelIRConnection();
    else if (delay == 0)
        DoAction();
    return event;
}

static Boolean SendPacket(UInt8 *dataP, UInt16 length)
{
    DataPacket.len = length;
    DataPacket.buff = dataP;
    SetState(kStateSendPacket);
    do
        ProcessOneEvent();
    while (State != kStateIdlea && State != kStateReady);
    DataPacket.buff = NULL;
    DataPacket.len = 0;
    return State != kStateIdle;
}

You might find this blocking API useful for other reasons. Above this, you
can use conventional programming, whereas below it, you have to use a state
machine. Email me privately if you want more details on this approach.
--
Danny @ Palm



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to