473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to Destroy/Dispose/Release an object which is created by IPersistStreamInit Interface

Hi,
After reading and applying the following sample/example from Charles Law,
who responded Vibhu Bansal's "createDocumentFromUrl usage in VB.NET /
loading a url using mshtml.createDocumentFromUrl " questions, I have
encountered a problem which I was fail to overcome. The problem is when I
multithreaded the example even though I
set all the variables and the threads to nothing, applications threads are
incresing over and over and at a point the whole screen is bloating with all
empty Internet Explorer Windows. I think I was not able to properly release
/ destroy or dispose these objects after I have finished my job with them.
If anyone has any idea about this situation I would really appreciate for
your help.

Thanks in advance,
Onur Buyukcaglar

PS: I feel that I have to implement IUnknown -> Release on
IPersistStreamInit, but I do not know how to do it in VB.NET.
Sample provided by Charles Law about usage of "CreateDocumentFromUrl in
Vb.Net" as follows.
Imports System.Runtime.InteropServices

<ComVisible(True), ComImport(),
Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)> _
Public Interface IPersistStreamInit
' IPersist interface
Sub GetClassID(ByRef pClassID As Guid)

<PreserveSig()> Function IsDirty() As Integer
<PreserveSig()> Function Load(ByVal pstm As UCOMIStream) As Integer
<PreserveSig()> Function Save(ByVal pstm As UCOMIStream, ByVal
ByValfClearDirty As Boolean) As Integer
<PreserveSig()> Function GetSizeMax(<InAttribute(), Out(),
MarshalAs(UnmanagedType.U8)> ByRef pcbSize As Long) As Integer
<PreserveSig()> Function InitNew() As Integer

End Interface
#Region " Imports "

Imports System
Imports System.Windows.Forms
Imports System.Runtime.InteropServices

#End Region

Module Module1

Dim IID_IHTMLElementRender As Guid = New
Guid("3050f669-98b5-11cf-bb82-00aa00bdce0b")

<MTAThread()> _
Sub Main()

Dim objMSHTML As mshtml.HTMLDocument
Dim objDocument As mshtml.IHTMLDocument2
Dim ips As IPersistStreamInit

objMSHTML = New mshtml.HTMLDocument

ips = DirectCast(objMSHTML, IPersistStreamInit)
ips.InitNew()

objDocument = objMSHTML.createDocumentFromUrl("http://www.msn.com",
String.Empty)

Do Until objDocument.readyState = "complete"
Threading.Thread.Sleep(1)
Loop

MessageBox.Show(objDocument.body.outerHTML)

End Sub

End Module
Nov 21 '05 #1
0 1528

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: faktujaa | last post by:
Hi All, A small confusion. I have defined a connection class that has System.Data.IDbConnection as a member variable and implements IDisposable interface. I have implemented Dispose method to call...
4
by: RiteshDotNet | last post by:
..net Frame work 1. Dispose Method what it does ? A. who its call / when it calls ? B. Is it fire automatically ? c. When dispose method is call what it does ? D. Release a Object from memory or...
11
by: Ken Durden | last post by:
I am in search of a comprehensive methodology of using these two object cleanup approaches to get rid of a number of bugs, unpleasantries, and cleanup-ordering issues we currently have in our...
24
by: Jazper | last post by:
hi i have this problem. i made a class deverted by CRootItem with implementation of IDisposable-Interface. i made a test-funktion to test my Dispose-Method.... but when set a breakpoint in my...
7
by: Tamir Khason | last post by:
I have a class public class Foo { public Foo() { DoSomething() } } I want to be able to do something else while the class enters GC - no more
3
by: Maxim | last post by:
Hi! According to documenation, if we need to release some umanaged resources manually, we need to implement IDisposable interface with single Dispose method. I am just wondering, what will...
7
by: gerry | last post by:
I have a com object that is used via an interop assembly - ie. I referenced the com object and vs.net created the interop .dll for it. I create one object per session when the page 1st loads and...
3
by: Matt B | last post by:
Subject is probably poorly worded, but bear with me as I describe the situation that has me puzzled. I create "Save" objects from a Save "factory" class. Many different windows access this...
4
by: Curious | last post by:
Hi, I have a timer object that's launched as below: mTimer = new System.Threading.Timer (new TimerCallBack(SubscribeTrade), null, 15000, 15000); void SubscribeTrade (object state) {...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.