Well not that I know of but I may have misunderstood 

There is one method which is called which 
= checks if the meteorological wind bitmap has already been downloaded and
saved to sdcard
= if it has it uses that 
= if not it downloads a new one and saves that (this is where the error
occurs

The overall methods is called as follows

ThreadPool.QueueUserWorkItem(o => getwindMethod(ds));

However there are 4 buttons which send a different parameter (date or
altitude) using 'ds' depending  on which button is pressed.
Does this constitute multiple threads?
I couldn’t see that it would because only one button can be pressed at a
time and the previous procedure must have completed first.
Secondly this error occurs even if one only presses on button and starts one
thread?

Have I misunderstood how threading works ?
Can other threads be started even if the button is not pressed?

Many thanks anyway Sri I really appreciate your help 

John Murray 



-----Original Message-----
From: monodroid-boun...@lists.ximian.com
[mailto:monodroid-boun...@lists.ximian.com] On Behalf Of SRI
Sent: 23 September 2011 14:50
To: j...@murray.gb.com; Discussions related to Mono for Android
Subject: Re: [mono-android] sharing violation trying to save a bitmap

Hi

          Are you creating multiple Threads to call saveBMP, In that
case only you will see this type of jumping in code?

Best Regards,
Sridharan Srinivasan
Alias Sri.

On Fri, Sep 23, 2011 at 6:57 PM, John Murray <j...@murray.gb.com> wrote:
> I cant understand what’s going on here
>
> In MonoDevelop I just get an unhandled exception
>
> In Vis studio I get more of a clue as it says there’s a sharing violation
>
>
>
> Weirdly stepping through in the debugger it seems to go round the loop
twice
> (i.e. it steps down to Bitmap.compress then springs back to the
File.Exists
> line and steps through it again
>
> hence one can understand that if the stream is already open there may be a
> sharing issue
>
> But why does it go round twice?  It gets to the line Bitmap.Compress()
then
> loops back to File.Exists();
>
> If I remove the File.Exists code then it crashes out at Bitmap.Compress
with
> the contradictory message
>
> “System.IO.IOException: Win32 IO returned ERROR_SUCCESS”
>
>
>
> If the File.Exists code is left in I get a sharing violation when it gets
to
> the Fielstream line
>
> Presumably because FS is still open having already run through that code
> once before.
>
> What is going on – why does it suddenly decide to revisit the earlier
lines
> of code? Or run through a line of code twice?
>
>
>
>
>
> public static void saveBMP(Context cntxt,string filename)
>
>         {
>
>             if (File.Exists(filename))     // shouldn't have to do this if
> FileShare.Delete is working as I understand it
>
>             {
>
>                 File.Delete(filename);      // on second loop around it
> deletes file but then there is an error with file does not exist
>
>             }
>
>
>
>             FileStream fs = new FileStream(filename, FileMode.Create,
> FileAccess.Write, FileShare.Delete);
>
>             System.IO.BufferedStream buf = new
System.IO.BufferedStream(fs);
>
>             Bitmap bmp = WXclass5.windmap;
>
>             bmp.Compress(Bitmap.CompressFormat.Png, 90, buf);
>
>             fs.Close();
>
>             buf.Close();
>
>             bmp = null;
>
>             //fout.Close();
>
>             WXclass5.pnglist = getlistpngs(cntxt);
>
>         }
>
>
>
>
>
> _______________________________________________
> Monodroid mailing list
> Monodroid@lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
>



-- 
Sridharan Srinivasan
Alias Sri
Ph:(65)98255785/(65)63922439
www.arshu.com
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to