c# - Parent object goes out of scope when I have captured child property - when does it dispose the child property? -



c# - Parent object goes out of scope when I have captured child property - when does it dispose the child property? -

i wasn't quite sure how word question, elaborate, i'm using aws sdk in asp.net web api 2 project , want homecoming response stream s3 object - stream delivered client , disposed.

what i'm unsure references s3 abstracted away ifilestore object in order decouple myself aws dependency. within file store, retrieve s3response object contains responsestream property. if s3response object disposed, dispose underlying responsestream. ifilestore returns stream though, bundle , homecoming api streamcontent.

given phone call filestore.getfile(...) , returns value of responsestream property , responsestream goes out of scope, have suspicion dispose potentially called on responsestream object parent during normal gc behaviour before http response completed.

how can maintain s3 abstracted away , ensure response stream disposed of 1 time http response completes?

one way bundle whole s3 response object generic container object implements stream proxy underlying stream can homecoming streamcontent api method, , have dispose method dispose entire underlying s3 response object when framework naturally calls dispose @ end of process. not sure if there's improve way though.

it may thought utilize pushstreamcontent stream info client asp.net web api. pushstreamcontent supports asynchronous data-producing lambda (func<task>), , client can start receiving content stream immediately.

here's great blog post on subject, sample code: "asynchronous streaming in asp.net webapi".

i can't speak aws sdk, ideally may able pump info asynchronously stream returned aws api straight stream beingness sent client of web api.

c# .net asp.net-web-api asp.net-web-api2 decoupling

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -