.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How can I maintain "state" across WCF method calls?

Posted By:      Posted Date: August 30, 2010    Points: 0   Category :WCF
I need to retrieve very large portions of NTFS files (as byte arrays) from a WCF Service.  The needed portions of the files are far too large to efficiently return in a single request, so I need a "chunky" implementation that will return just a portion of the file on each method call. But the entire process needs to be very fast... specifically: I need to avoid the overhead of re-opening the file each time the client requests the next "chunk". So how can I keep the filestream open on the service-side in anticipation of the next request from the client for the next chunk? And if no subsequent request arrives, then close the filestream? That is, implement "lazy close". Or stated another way: Does the code instantiated on the service-side to service an incoming method call remain "alive" after the method returns to the caller?  Or can it be configured that way, like a Singleton SAO behaves in Remoting?? Thanks, DT 

View Complete Post

More Related Resource Links

.NET Delegates: Making Asynchronous Method Calls in the .NET Environment


One of the many great features of the .NET Framework is that it has asynchronous infrastructure built in. In .NET you can call any method asynchronously by defining a delegate for the method and calling the delegate's asynchronous methods. This is beneficial to your application because when a synchronous call is made, the calling thread is blocked until the method completes whereas an asynchronous call is made on a different thread, and this allows the original thread to continue its work while the asynchronous call is in progress.This article explains delegates in .NET and how to use them to perform asynchronous calls, eliminating age-old threading problems.

Richard Grimes

MSDN Magazine August 2001

Windows 2000: Asynchronous Method Calls Eliminate the Wait for COM Clients and Servers


Windows 2000 is the first version of COM to support asynchronous method calls, which permit clients to make nonblocking calls to COM objects and objects to process incoming calls without blocking the calling threads. COM clients benefit from asynchronous method calls because they can continue working while waiting for outbound calls to return. Objects benefit because they can queue incoming calls and service them from a thread pool. Our SieveClient and SieveServer sample apps demonstrate how to create and use asynchronous clients and servers in COM-based distributed applications.

Jeff Prosise

MSDN Magazine April 2000

Maintain Controls State on Master Page.

I have Web Application which uses the Logged In User (Authenticated User) to query his Profile Data from Adabas/Unix using OLEDB. The application provides the user with about 21 different pages (Basic Info, Employment Info, Education, Dependants, Financial Info ...). The web application has a master page, and each profile data page is based on a User Control loaded in the Child ASPX Page. Since we are migrating our legacy applications from Adabas/Unix to SAP, the development Team has prepared web services to query for the same Profile Data from SAP using Web Services. Now, we have to modify the web application to consume the web services instead of using OLEDB to query Adabas. Since we are in the testing phase, and we have only very limited data in SAP, I have to provide temporary control to allow test query the Staff Profile for a Specified User (instead of the Authenticated User) and to select the Source: 1. SAP, or 2. Adabas.   So I am thinking to add the following "Control Section" in the Master Page:<div runat="server" id="divSAPTest" class="SAPTest"> <span>Test SAP Web Services. Enter Staff ID: </span> <asp:TextBox ID="txtSAPStaffID" runat="server" Width="60px"></asp:TextBox> <span>From: </span> <asp:DropDo

Where to maintain state on server

Hi,I am developing a feature in my app where I need to store the state of a particular series of actions between 2 users, just like an ajax based chat service. Where do I store the state? Or taking the example of Ajax based chat, where should I store what message User1 entered and when Uer1 entered how is it shown to user2?I was thinking application object but read it is not recmmended. 

How to maintain checkbox state in paging

Hi GuysI am using dot net 3.5.I have a grid in which there are text box and check box as template column.But when I move from one page to another the value of checked check box is lost.How to maintain the value through all the pages in grid.RegardsUnmesh 

how to maintain state of accordion pane from one page to another

 Hi,   I am using accordion control in one of my project. I want to maintain the state of the accordion pane when the user navigates from one page to another. Can someone help me  ?? Below given is the code of my accordion control I do not want to use query string because i am using url rewriting. <cc1:Accordion   ID="accNavMenu" runat="server" TransitionDuration="100"    FramesPerSecond="200" FadeTransitions="true" RequireOpenedPane="false"    OnItemDataBound="accNavMenu_ItemDataBound"   ContentCssClass="sidenav2" HeaderCssClass="sidenav"    HeaderSelectedCssClass="acc-selected">    <HeaderTemplate>    <asp:HiddenField ID="hdTemplate" runat="server"           Value='<%# DataBinder.Eval(Container.DataItem,"Template") %>'      />     <asp:HiddenField ID="hdSectionID" runat="server"           Value='<%# DataBinder.Eval(Container.DataItem,"SectionID") %>'      />    <table cellpadding="0" cellspacing=&quo

How Do I maintain the chronological order in which Asynchronous delegate calls are made?


I have created a basic logging framework for my application that writes log messages to a local text file using an Asynchronous delegate.

My application has many threads running however, and as a result, the order of the log entries in the text file is not chronological.

So I have two competing requirements: on one hand, my WriteToLog() method has to return almost immediately so that it doesn't block in-flight code, while at the same time the log file has to be in chronological order.

Any ideas?  Some of the problems I've encountered are:

1a.  Trying to use a Queue (with a lock{ } around it) to maintain the order seems to result in deadlocks

1b.  Even if I use a Queue, at some point the Queue must be written to disk, so it seems like I'd have to frequently have WriteToLog spin off a "WriteToDisk" like method.

2a.  I've considered instantiating a new thread which polls the Queue from (1a) and writes to disk in a loop, say, every 5 seconds.  I'm leaning more towards this method.

3.  I've looked into log4net and some other stuff but it just seems like overkill, and I'd really like to have my own framework for this seemingly simple task.



How to maintain a state value after user signoff from the application


The above u mention with out session how to maintain the user value in that invitation page?
My secenario like as our Picasa album, the corner of the picasa album shows the "owner of the ablum(username)".
In my scenario also the invitation should contain both login user name and friend name.
Please guide me.

how to maintain state in menu control in asp.net 4.0



I am working  on vs. 2010. I have menu control in master page.

my menu having two pages  default1.aspx, default2.aspx .

when user enter some values in default1.aspx page after click default2.aspx and enter some  values

now  if I click default1.apx page doesn't having values. but i want  to maintain those values  in my all pages .


Could any body help me on this requirement.




Serializing to file system to maintain state



I have a system that has several large objects that need to be built and populated each and every time, and these objects may be accessed quite often as well. As a strategy, caching would not be that good for me because there are potentially thousands of these objects which are fairly large. So I propose to serialize the objects to the file system and then deserialize it when I need those objects again. I have several classes that need this serialization functionality.

These objects change as well, so on the next access I check if there were any changes and then I grab only the changes and edit the object, and then reserialize the object.

My question is what is the best way to do this, since I have several classes ... I need some design pattern or strategy that would help me make this a breeze to implement on several classes.

Thanks in advance

Method calls from try/catch


Hi All,

Was wondering ... if I have a method call from within a try/catch and the method (with no internal error handling) throws a runtime error, will the error get caught in the catch block of the try/catch that called the method in the first place?

Thinking about new C# method prototypes: object as dictionary

I recently had to write a small Flickr API. I know many .Net API for Flickr already exist but I needed one for a Silverlight application. Whatever, it's only about building some querystrings so I did it by myself. It's been an opportunity to think again about a classical question: how to pass parameters to a method ?

Imagine you have a generic method to call some Flickr functions.

Truly Understanding View State

This article provides a detailed understanding of the ViewState.

Enabling Users to Maintain SharePoint Content

When SharePoint is installed as a corporate intranet, there is a considerable amount of effort involved in maintaining the content to keep the site relevant. As we discussed in the first few parts of this series, SharePoint has many built-in features to reduce the burden on the site administrator.

Some areas of the site usually contain less-dynamic information. Internal memos and corporate policies are common examples of this information. One option for this information is to post these documents in a document library. Documents in a library are often stored in a few different formats: Word, Acrobat (PDF), or HTML. Each of these formats has its drawbacks.

Maintain HTML Radio Button Selection Inside GridView After Postback

Long time ago I wrote an article about getting the value of the selected RadioButtons inside the GridView control. The code did not addresssed the postback issue which means that the selected radio button was cleared after the postback occurs.

Enabling Users to Maintain SharePoint Content

When SharePoint is installed as a corporate intranet, there is a considerable amount of effort involved in maintaining the content to keep the site relevant. As we discussed in the first few parts of this series, SharePoint has many built-in features to reduce the burden on the site administrator.

Using JQuery to perform Ajax calls in ASP.NET MVC

The muscle behind the actual asynchronous calls comes from JavaScript. I looked around at a bunch of existing JavaScript libraries and settled on JQuery because of the way it leverages existing CSS knowledge. The three things that the library should do easily are:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend