nsresult rv; nsCOMPtr<nsIEventQueueService> service = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv;  nsCOMPtr<nsIEventQueue> currentThreadQ; rv = service->PushThreadEventQueue(getter_AddRefs(currentThreadQ)); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
nsCOMPtr<nsIStringBundleService> sbServ(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res)); if (NS_FAILED(res)) return res;
nsStringBundle::Init(const char* aURLSpec){#if defined(DEBUG_tao)  printf("\n-->nsStringBundle::Init: aURLSpec=%s\n", aURLSpec);#endif  //  // use eventloop instead  //  // create an event queue for this thread.  nsresult rv;  nsCOMPtr<nsIEventQueueService> service = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv);  if (NS_FAILED(rv)) return rv;    nsCOMPtr<nsIEventQueue> currentThreadQ;  rv = service->PushThreadEventQueue(getter_AddRefs(currentThreadQ));  NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);  nsCOMPtr<nsIURI> uri;  rv = NS_NewURI(getter_AddRefs(uri), aURLSpec);  if (NS_FAILED(rv)) return rv;  //   create and loader, then wait  nsCOMPtr<nsIStreamLoader> loader;  rv = NS_NewStreamLoader(getter_AddRefs(loader),                           uri,                           this /*the load observer*/);  NS_ASSERTION(NS_SUCCEEDED(rv), "\n-->nsStringBundle::Init: NS_NewStreamLoader failed...\n");  // process events until we're finished.#ifdef DEBUG_tao  printf("\n-->nsStringBundle::Init: LOOP....\n\n");#endif  PLEvent *event;  while (!mLoaded) {    rv = currentThreadQ->WaitForEvent(&event);    NS_ASSERTION(NS_SUCCEEDED(rv), "\n-->nsStringBundle::Init: currentThreadQ->WaitForEvent failed...\n");    if (NS_FAILED(rv)) return rv;    rv = currentThreadQ->HandleEvent(event);    NS_ASSERTION(NS_SUCCEEDED(rv), "\n-->nsStringBundle::Init: currentThreadQ->HandleEvent failed...\n");    if (NS_FAILED(rv)) return rv;  }#ifdef DEBUG_tao  printf("\n-->nsStringBundle::Init: out of LOOP....\n");#endif  rv = service->PopThreadEventQueue(currentThreadQ);  return rv;}