CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Oct 2005
    Location
    Norway
    Posts
    120

    Terminate implicit session w/linq?

    Hello, experts!

    I need help with a scenario:

    I have a photography server that builds image paths dynamically to clients for downloading. This works as intended except for the following:

    Each time a viewer wants an image preview, a new session is created on the server, terminating only one hour later. When there is lots of traffic, the sessions accumulate, and end up overwhelming the server.

    I initially loaded the image uri more or less like this:

    Code:
    -- snip --
    string xmlSourceUrl = GetImageUrl( );
    
    XElement sourceRoot = XElement.Load( xmlSourceUrl );
    
    string result = ( from file in sourceRoot.Descendants( "PreviewUrl" ) select sourceRoot.Value ).Single< string >( );
    -- snip --
    Which is bad. It looks like linq for Xml supports loading xml directly over http, but there is no way to tell it afterwards that the session should end immediately.

    I tried using a WebClient object, but I cannot find a "Terminate", "Close", "Abandon" or any other function to indicate that I would like the session to end immediately after reading the stream.
    Here is how it looks:
    Code:
    			// Create a webclient object to read with
    			WebClient wc = new WebClient( );
    			
    			// prepare a reader object
    			TextReader reader = new StreamReader( wc.OpenRead( completeUrl ) );
    
    			/// To XElement using the reader
    			XElement result = XElement.Load( reader , LoadOptions.None );
    
    			// Close the reader
    			reader.Close( );
    
    			// client goes out of scope here - does session terminate?
    			return result;
    Can anyone help please?
    Last edited by Efitap; October 19th, 2008 at 06:51 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured