Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8211413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:25:11+00:00 2026-06-07T10:25:11+00:00

I know Bitmaps are not threadsafe, and hence using this workaround Bitmap[] blobCopies =

  • 0

I know Bitmaps are not threadsafe, and hence using this workaround

                   Bitmap[] blobCopies = MakeBlobCopies(bmpBlob, 2);

                    BackgroundWorker bw1 = new BackgroundWorker();
                    bw1.DoWork += new DoWorkEventHandler(bw1_DoWork);
                    bw1.RunWorkerAsync(blobCopies[0]);

                    BackgroundWorker bw2 = new BackgroundWorker();
                    bw2.DoWork += new DoWorkEventHandler(bw2_DoWork);
                    bw2.RunWorkerAsync(blobCopies[1]);

                    DisposeBlobCopies(blobCopies);

In the Backgroundwork event handle , I apply some filters to the bitmaps but I get the an Access Violation Exception


System.AccessViolationException was unhandled
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=System.Drawing
  StackTrace:
       at System.Drawing.SafeNativeMethods.Gdip.GdipBitmapLockBits(HandleRef bitmap, GPRECT& rect, ImageLockMode flags, PixelFormat format, BitmapData lockedBitmapData)
       at System.Drawing.Bitmap.LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format, BitmapData bitmapData)
       at System.Drawing.Bitmap.LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format)

I am not even disposing the bitmaps (which I would need to avoid choking up memory). BUt still get this exception. I do not need to return anything from the worker thread, the
Is this the right away to even approach this? Any ideas?

    private Bitmap[] MakeBlobCopies(Bitmap originalBitmap, int n)
    {
        Bitmap[] blobCopies = new Bitmap[n];
        for (int i = 0; i < n; i++)
        {
            blobCopies[i] = (Bitmap)originalBitmap.Clone();
        }
        return blobCopies;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:25:13+00:00Added an answer on June 7, 2026 at 10:25 am

    No, bitmaps are thread-safe. They are protected by an internal lock, you’ll get an exception when you try to read a bitmap when it is being written to by another thread.

    Disposing the bitmaps while the threads are using them is however hazardous, that jerks the floor mat. Especially when you use Bitmap.Clone(), it doesn’t make a copy of the pixel data. Only the Bitmap(Image) constructor does that. You’ll need to find a better place for the Bitmap.Dispose() call. Like in the DoWork or RunWorkerCompleted event handler, after you are sure that the bitmap isn’t going to be accessed anymore.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not sure the best way to ask this question. I am new
Does anybody know a good C sample that loads bitmaps and handles all the
I know how to make a background pattern repeating a bitmap. I also saw
Know this might be rather basic, but I been trying to figure out how
Know if it's possible to access the iPhone compass in Safari using JavaScript? I
I know you can not set a key value dynamically, but what about the
I know that this sort of question has been asked here before, but still
i know this is a stupid question but i d'ont know how to do
I am using the following sample at http://blogs.msdn.com/dwayneneed/archive/2007/10/05/blurry-bitmaps.aspx within VB.NET. The code is shown
Not sure how to explain this, so I'll first post some code and then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.