Richard
4/29/2005 10:16:00 PM
Hi Scott, thanks for your reply. I''m not caching the sortedlist such as in a
session object, so how can it be reused by the server?
It''s declared in a module:
Module mdlGeneral
Public Itinerary As SortedList
End Module
Then it is instantiated and used in a click event:
Private Sub btnAddToItinerary_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnAddToItinerary.Click
''Create the object if necessary.
If Itinerary Is Nothing Then
Itinerary = New SortedList
End If
''Look for the issue id first. Add it if not already in the sortedlist.
If
Itinerary.ContainsKey(Session("ServiceIssueDetailIssueID").ToString) = False
Then
Itinerary.Add(Session("ServiceIssueDetailIssueID").ToString,
Session("ServiceIssueDetailIssueDescription").ToString)
End If
End Sub
"Scott M." wrote:
> The browser has absolutely nothing to do with it. The server has no way of
> knowing when a browser closes. In fact, by the time the browser even gets
> the page, the server has already finished its processing and has
> disconnected from the client.
>
> All of your object variables will fall out of scope when the page finishes
> its server-side processing. The objects themselves will remain in memory
> until the Garbage Collector cleans up the heap.
>
> Your problem sounds more like your are caching some results somewhere and
> the server is reusing those results for new page requests.
>
>
> "Richard" <Richard@discussions.microsoft.com> wrote in message
> news:71C59AAC-9FD7-406A-B724-75C4A4BFA914@microsoft.com...
> > I''m running into a problem with objects not destroying when the browser
> > closes and is reopened. I have a custom collection that is declared public
> > in
> > a module, and instantiated elsewhere (linkbutton click event). The
> > collection
> > works fine, but when I close the browser and then I restart the web app,
> > the
> > collection is still instantiated and contains alll of the items it had
> > before
> > the browser was closed!
> >
> > I was under the impression that once the browser closes, all objects go
> > with
> > it. What I''ve been doing to "fix" this is in the main.aspx''s pageload
> > event,
> > checking if the object is not nothing, and clearing it if it is. This is
> > not
> > limited to custom collections; I have a sortedlist class that is also
> > still
> > "active" once the browser closes and then is restarted:
> >
> > If Itinerary Is Nothing Then
> > Itinerary = New SortedList
> > Else
> > Itinerary.Clear()
> > Itinerary = Nothing
> > Itinerary = New SortedList
> > End If
> >
> > Other than the above method, how can I ensure that my objects die when the
> > user clicks on the close button on the browser?
> >
> > Thank you,
> > Richard
>
>
>