Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c# - NetworkStream Pooling -


i have multi-threaded application communicates server on tcp connection. application deployed windows service.

the way has been implemeted is, there controller creates communicator objects, assigns port number, message count etc. properties communicator , invokes startclient method commence dialog server.

within startclient method, each communicator object creates connection server, using port number , url specified controller. after establishing connection, internally creates thread , calls readmessages method keeps reading server till message count met , gets closed down.

based on runtime conditions, there might need reuse communicator object talk server again , hence, readmessages method woudl called again.

initially, had been calling dispose() method networkstream, streamreader , streamwriter objects when readmessages method completed, reconnecting scenario, used throw "cannot access disposed object" error. so, commented out dispose method call testing.

as of now, works fine, concerned that, isnt best way achieve functionlity not disposing objects ever.

i thinking in terms of object pooling, if possible have pool of stream objects reused different threads?

one way tackle can create new instance of stream objects each time communicator connects server, think expensive operation.

can please me identify better approach handle situation here can reuse communicator object without performance hit?

the approach based on how need read messages - if occasional n, recommend re-factor communicator object make "readmessages" operation atomic - i.e. connect server, create network stream, read messages , dispose every thing.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -