Last post Feb 14, 2011 04:22 AM by bala.sekhar
Feb 13, 2011 05:42 AM|wigginal|LINK
I am working on a web service that return image tiles for site using Bing Maps. The problem I am having is that All these tiles are created using a single data source. When the bing maps control calls out for the imagery it calls the service multiple times
to get the tiles it needs. So if the first thread to go in gets the file all the other threads will fail until the first thread is done reading in the file. Is there an easy way to share this file between all the requests?
The flow for what im trying to do is as follows:
open file and read in the data to a custom class - (this is the class I would like to share for all the threads)
create the image based on the data
return the image
Feb 14, 2011 02:19 AM|bala.sekhar|LINK
if it is only read-only operation on the file, then you can open the file in read mode with shareable option enabled. That will resolve your problem.
Feb 14, 2011 03:22 AM|wigginal|LINK
While this will work if I want to read in the same file for each image I am trying to create, I was hoping there was a way to share the object after it is read in the first time so the rest of the threads dont have to waste the time doing it over and over.
Feb 14, 2011 04:22 AM|bala.sekhar|LINK
If i understood your problem correctly, you are trying to read something from a file when it is read for the first time and on subsequent requests you want to make use of the content which is already read into memory. Thus avoiding, IO read operation.
Try out creating your custom class as a Singleton. That should address your problem.