nsCOMPtr<nsIEventQueueService> service = do_GetService(NS_EVENTQUEUESERVICE_PROGID, &rv);
nsCOMPtr<nsIEventQueueService> service = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv);
nsSyncHelper::Run(){    nsresult rv = NS_OK;    if (!mChannel || !mListener) return NS_ERROR_NOT_INITIALIZED;    // create an event queue for this thread.        nsCOMPtr<nsIEventQueueService> service = do_GetService(NS_EVENTQUEUESERVICE_PROGID, &rv);    if (NS_FAILED(rv)) return rv;    rv = service->CreateThreadEventQueue();    if (NS_FAILED(rv)) return rv;    nsCOMPtr<nsIEventQueue> currentThreadQ;    rv = service->GetThreadEventQueue(NS_CURRENT_THREAD,                                   getter_AddRefs(currentThreadQ));    if (NS_FAILED(rv)) return rv;            // initiate the AsyncRead from this thread so events are    // sent here for processing.    rv = mChannel->AsyncRead(this, nsnull);    if (NS_FAILED(rv)) return rv;    // process events until we're finished.    PLEvent *event;    while (mProcessing) {        rv = currentThreadQ->WaitForEvent(&event);        if (NS_FAILED(rv)) return rv;        rv = currentThreadQ->HandleEvent(event);        if (NS_FAILED(rv)) return rv;    }    rv = service->DestroyThreadEventQueue();    if (NS_FAILED(rv)) return rv;    // XXX make sure cleanup happens on the calling thread.    return NS_OK;}