Hello all,
I know this question has already asked but I can't do it.
If someone can help me with code sample or link.
or if someone want to read my code at the end and tell me what is wrong.
thanks in advance
the following code works only in debug mode with this message :
###!!! ASSERTION: nsDOMEvent not thread-safe: '_mOwningThread.GetThread()
== PR_GetCurrentThread()', file nsDOMEvent.cpp, line 290
and of course I would like it works with a normal compilation
my source :
myThread(void* arg){
...
nsIDOMEvent* ev=nsnull;
nsIDOMEvent** aEv = &ev;
if (proxyDomDocEvent) {
proxyDomDocEvent->CreateEvent(NS_LITERAL_STRING("KeyEvents"), aEv);
}
nsCOMPtr<nsIDOMKeyEvent> kev=do_QueryInterface(ev);
if (kev) {
kev->InitKeyEvent(NS_LITERAL_STRING("keypress"),PR_TRUE,PR_TRUE,
nsnull,PR_FALSE, PR_FALSE,PR_FALSE,PR_FALSE,myCode,myType);
PRBool noDefault;
//send the Event
proxyDomDocTarget->DispatchEvent(ev, &noDefault);
}
...
}
Init(nsIDOMDocument *document, nsIDOMNode *nodl){
...
domDocEvent = do_QueryInterface(document);
domDocTarget=do_QueryInterface(nod);
//proxy Manager Creation
nsServiceManager::GetService( NS_XPCOMPROXY_CONTRACTID,
NS_GET_IID(nsIProxyObjectManager),
(nsISupports **)&manager);
//proxyCreation
manager->GetProxyForObject( NS_UI_THREAD_EVENTQ,
NS_GET_IID(nsIDOMEventTarget),
domDocTarget,
PROXY_SYNC | PROXY_ALWAYS,
(void**)&proxyDomDocTarget);
manager->GetProxyForObject( NS_UI_THREAD_EVENTQ,
NS_GET_IID(nsIDOMDocumentEvent),
domDocEvent,
PROXY_SYNC | PROXY_ALWAYS,
(void**)&proxyDomDocEvent);
// thread Creation:
myKeyThread=PR_CreateThread(PR_USER_THREAD,myThread,
(void*)nsnull,PR_PRIORITY_NORMAL,PR_LOCAL_THREAD,PR_JOINABLE_THREAD,0);
return NS_OK;
}