Thread & Webgadget & Com question

Just starting out? Need help? Post your questions and find answers here.
Rascal
User
User
Posts: 30
Joined: Mon Sep 17, 2007 11:06 pm

Thread & Webgadget & Com question

Post by Rascal »

Code in the second cycle after the error has occurred.

I now propose to the problem, and before the issue is absolutely not the same,

No previous use of threads.

Now the use of the thread.

trouble you to help solve the problem.

This problem has been bothering the good days.

Code: Select all


Enumeration 
  #Web_0 
  #Panel_0 
  #Window_0 
EndEnumeration 

Declare   Main() 
Declare   WebBrowser_(INT.l) 
Declare.l WebBrowser_Refresh(Gadget.l) 

;- 
Procedure WebBrowser_(INT.l) 
Url.s = PeekS(INT) 
If OpenWindow(#Window_0,#Null,#Null,1000,700,#NULL$,#PB_Window_SystemMenu) 
 If CreateGadgetList(WindowID(#Window_0)) 
     PanelGadget(#Panel_0,#Null,#Null,1000,700) 
     AddGadgetItem(#Panel_0,1,"Ok") 
     WebGadget(#Web_0,#Null,#Null,WindowWidth(#Window_0)-3,WindowHeight(#Window_0)-22,Url) 
     CloseGadgetList() 
 EndIf 
 Repeat 
 Until WaitWindowEvent() = #PB_Event_CloseWindow 
EndIf 
EndProcedure 

;- 
Procedure.l WebBrowser_Refresh(Gadget.l) 
CoInitialize_(#Null)
Res.l                         = #False
IWebBrowser2.IWebBrowser2     = GetWindowLong_(GadgetID(Gadget),#GWL_USERDATA) 
IDispatch.IDispatch           = #Null
IHTMLDocument2.IHTMLDocument2 = #Null
If IWebBrowser2
 If IWebBrowser2\get_Document(@IDispatch) = #S_OK And IDispatch
  If IDispatch\QueryInterface(?IID_IHTMLDocument2,@IHTMLDocument2) = #S_OK And IHTMLDocument2
   If IHTMLDocument2\execCommand("Refresh",#VARIANT_TRUE,@VAR.VARIANT,@pfRet) = #S_OK
      Res = #True
   EndIf
   IHTMLDocument2\Release()
  EndIf
  IDispatch\Release()
 EndIf
EndIf
CoUninitialize_()
ProcedureReturn Res 
EndProcedure 

DataSection 
  IID_IHTMLDocument2:
    Data.l $332C4425 
    Data.w $26CB, $11D0 
    Data.b $B4, $83, $00, $C0, $4F, $D9, $01, $19
EndDataSection

;- 
Procedure Main() 
While #True 
Url.s = "about:blank" 
Thread.l = CreateThread(@WebBrowser_(),@Url) 
Sleep_(1000*5) 

Debug WebBrowser_Refresh(#Web_0) 
Sleep_(1000*5) 

KillThread(Thread) 
Wend 
EndProcedure 

WaitThread(CreateThread(@Main(),#Null))

[02:17:29] Waiting for executable to start...
[02:17:29] Executable started.
[02:17:44] [ERROR] WebBrowser.pb (Line: 36)
[02:17:44] [ERROR] Invalid memory access. (write error at address 56)
[02:17:47] The Program was killed.
Last edited by Rascal on Sat Aug 23, 2008 7:18 pm, edited 8 times in total.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Rascal, tell us what you are trying to accomplish with your program and maybe helping you will be easier....then you can stop creating new threads for the same problem.

Also, read the PB help file and look under WebGadget. It will be very refreshing.
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
freak
PureBasic Team
PureBasic Team
Posts: 5946
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Stop creating new topics about the same thing. It is annoying.
If people didn't help you in the previous topics, they won't help you here either.

As for your problems:
Just don't use threads with the WebGadget. COM+Threads is just not a good combination.
quidquid Latine dictum sit altum videtur
Little John
Addict
Addict
Posts: 4801
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post by Little John »

... and try to write complete and understandable sentences.
Otherwise it's simply (almost) impossible to help you!

Annoyed, Little John
Rascal
User
User
Posts: 30
Joined: Mon Sep 17, 2007 11:06 pm

Post by Rascal »

Nobody knows to solve problem ???
freak
PureBasic Team
PureBasic Team
Posts: 5946
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

I told you: WebGadget+Threads=trouble. Just don't do it.
quidquid Latine dictum sit altum videtur
Rascal
User
User
Posts: 30
Joined: Mon Sep 17, 2007 11:06 pm

Post by Rascal »

I must do this procedure ah.
Or trouble you to help me solve
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Maybe if you would tell us what it is you are trying to accomplish here, we could offer some help. Your communication skills need some work. ;)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Post Reply