.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

SQL CE 3.5 SP2 and backgroundworker

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :Sql Server


I try to query my SQL CE database in 2 background workers simultaneously.

It raises an AccessViolationException with the following message: attempted to read or write protected memory[...]

Does SQL CE 3.5 support this kind of scenario?

Please notice that the same source code works with SQL Server 2008 Express and MARS (Multiple Active Result Set) set to true.

If it does not support, what is the workaround ?


thx in advance for your help

Xavier Maurin

View Complete Post

More Related Resource Links

Webmethod backgroundworker freezes client

Hi guys,I am writing a webservice which has to perform a long running job. It is a requirement that I call the webmethod synchronously but the webmethod executes another method asynchronously and returns to the client. So I used a background worker on the webmethod to run and I call it asynchronously, then the method returns. Unfortunately the client still waits until the backgroundworker is completed.Below is a sample code to simulate the problem:using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Services;using System.ComponentModel;namespace BackgroundWorkerTest{    /// <summary>    /// Summary description for Service1    /// </summary>    [WebService(Namespace = "http://tempuri.org/")]    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]    [System.ComponentModel.ToolboxItem(false)]    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.     // [System.Web.Script.Services.ScriptService]    public class Service1 : System.Web.Services.WebService    {        BackgroundWorker bkgW = null;        [WebMethod]    &n

BackgroundWorker dont works starting an user control on MVVM



I have a problem using backgroundworker object.

If I use a code to load with Entity Framework a SQL table for fill a combobox, the program takes a lot of time and user experience is bad.
If I use a backgroundworker object, simply the combobox is'nt filled; my MVVM class that have a public property ObservableCollection<MyRecord>. I debug the code and this collection is filled right but WPF appears dont know that collection is recently filled. I try to use on Source property of combo the OneWay and TwoWay attributes, but dont work

I'm sure that any thing do it bad ¿Any body can tell me where try to fix up the problem?

    Private Sub LoadCountries()

'This code works fine, but user experience is affected
      'Me.Recursos = New ObservableCollection(Of Recurso)(Application.Contexto.Recursos.Include("User"))

      Using worker As New BackgroundWorker()

        Dim p As System.ComponentModel.DoWorkEventHandler =

Task vs. Backgroundworker



in .Net 4.0 there is a new "Task" class. Currently I'm using BackgroundWorkers for my background tasks. Should I use the new "Task" class instead? What are the benefits/drawbacks with the Task class?

Thanks for your help.



Progress bar with backgroundworker


Hi frnds :)

i hv 5 process in my application

for Eg. : P1, P2,p3,p4,p5

When process executed then i hv display back ground msg with progress bar

            if (P1 is completed)

                     MSG: P1 process has completed


                       MSG: Error has occured + what error has occured

                      Stop executing all process

plz let me know how to do this.. its very urgent

Many thanks in advance :) :)

Arguments in BackgroundWorker



I'm in need of a best solution. Situation is as follows: I intend to use BackgroundWorker to run database queries. Queries themselves require a diverse set of parameters collected (strings, dates, integers, arrays...) from the windows form of some sort. So far I have thousands of forms and twice as much SQL query methods in my solution and I have to make a coding standard for my team on how to implement the backgroundworker efficiently on those forms. So, the question is how to deliver those arguments to a worker thread while maintaining ease of maintenance and readability.

Bundling them to object[] array and pushing them trough an e.Argument reference is not very good solution, for example. It would work but if I have 20something parameters, using them is a coding nightmare (ie. (DateTime?)args[16]) not to mention what it takes if a want to remove a parameter or how to handle null values (we always use int?, DateTime?...).

Any suggestion is appreciated. Thanks.


ProgressChanged event randomly fires with BackgroundWorker?

I'm using a background worker for a Windows Form app I'm writing - .NET 3.5.

I'm using the background worker so that I can keep my user interface responsive (i.e. don't need to use Application.DoEvents) specifically when using Progressbar and status messages.  However, what I've noticed is that during my DoWork method when I do a .ReportProgress(somevalue, somemsg) it doesn't fire the ProgressChanged event immediately, it often fires longer after I've moved onto other processing. 

The end result is that the Progress bar gets update later than the actual processing being done, in some cases it's way out of synch.  So at this point I'm sorta wondering why I should even bother with Background worker threads when an Application.DoEvents on the main thread will accomplish a more accurate synch'd UI update??

Am I missing something?  Is my choice of BackgroundWorker a bad one?  Should I just go with System.Threading and manage all the work around that rather than trying the more simple BackgroundWorker?

Thanks, Rob.

Update a WPF Form from an object within a BackgroundWorker


Hello together,

I got stuck. :(  I want to capture a lot of images from a camera and after every new image, my UI should be updated ...

There is a Camera class (singleton) with a Capture method. This is doing the capturing of the data and stores them into an array. If I start now a measuring, a WPF form (e.g. with an image control and an abort button) should open and start the capturing of the images in the background. This is not a problem. But if I want to update the image control after every new image, my Camera.Capture method has to "inform" the form about that. But how? It tried to pass a delegate to the Camera.Capture method. But if this is called, it throws a System.Reflection.TargetInvocationException.

What is the "right / best" way to do this?


Thank you,


Issue with using the BackgroundWorker - frozen screen and wait cursor not displayed


I have 2 issues which are probably related:

1. My wait cursor does not display
2. My screen is frozen so I cannot click the "Cancel" button to stop the BackgroundWorker thread.

Here is what my code looks like, (I followed the example given at http://msdn.microsoft.com/en-us/library/cc221403(VS.95).aspx )

Class Home

   Dim bkwk As New BackgroundWorker


Public Sub New()

   bkwk.WorkerSupportsCancellation = True

   AddHandler bkwk.DoWork, AddressOf bw_DoWork
   AddHandler bkwk.RunWorkerCompleted, AddressOf bw_RunWorkerCompleted

End Sub

Private Sub btnPreview_Click(ByVal sender As Object, ByVal e As  System.Windows.RoutedEventArgs) Handles btnPreview.Click
      If Not bkwk.IsBusy = True Then
                Cursor = Cursors.Wait
                txtStatus.Text = "Busy ..."
      End If

BackgroundWorker component



You create a Windows Forms application. The application acts as a Web services client. Typically, the servers respond quickly; however, one specific type of transaction requires multiple different Web services requests and may take ten or twenty seconds to complete. To enable your application to continue to respond to user input, you implement a BackgroundWorker component to perform the Web services requests.

You want to display a progress bar that regularly updates to inform the user of the progress. What is the best way to do this? (Choose all that apply.)

  1. From within your form, create a timer that elapses every second. Respond to the timer by calling BackgroundWorker.ProgressChanged. Examine the returned value to update the progress bar.
  2. Create an event handler for the BackgroundWorker.ProgressChanged event and update the progress bar from within that event handler. From within your form, create a timer that elapses every second. Respond to the timer by calling BackgroundWorker.ReportProgress.
  3. Create an event handler for the BackgroundWorker.ProgressChanged event and update the progress bar from within that event handler. From within the BackgroundWorker process, call the BackgroundWorker.ReportProgress method each time a portion of the task is completed.
  4. From within your form, create a timer that elapses e

UserControl + StatusBar + backgroundworker


Hi all,

i have got a problem while studying with Usercontrol and statusbar. That is that I have got a main form,a status strip with toolsstrip progressbar and some Usercontrols. I use UserControl like a form. i have got one UserControl for each form.On each userControl, I have got some components- buttons,labels, one datagridview.And there is a menu panel on my mainform that is about UserControl calling links.When I press a link on this menu panel,I want to call one of this UserControl and load my datagridview while my Usercontrol is loading.I saw many articles and forums posts about "backgroundworker" component.I tried to implement with my main form to do thing that I aimed.But, it gives me an error.i couldn't understand too much.i designed my UserControl with .NET components.My mainform codes are below about backgroundworker component:


//my public variables each usercontrol instances to use from my ShowPanel() method

        public ucMemberList ucMList = new ucMemberList();

        public ucRecordList ucRList = new ucRecordList();


         private void xplMemberList_Click(object sender, EventArgs e)



Backgroundworker cancellation


Suppose I want to cancell a backgroundworker, does it raise an event?


backgroundworker - verify if all threading are closed


I have an application that uploads about 30 files on a server. I used a backgoundworker for ech of them. I have a "Close" button which should be eanbled when all files are uploaded  (so when all backgroundworker threads are closed).

How can I do that?


Thank you for your time!

adrian socolescu

Upload buffer report: Ui to SQL via WCF for BackgroundWorker Progressbar



I am trying to solve a little mystery. The WPF program that I am working on allows the user to upload a large local image (a scanned image of a birth certificate). The image is converted into a ByteArray. The ByteArrays are large +700K, therefore the upload to SQL 2008 Srv. Media Dbase runs in a backgroundworker process. My question is the following: since I am not using a filestream or memory stream to upload the ByteArray to Sql Server, but a regular Insert Into or Update command and BasicHttp WCF Protocol, is there a buffer anywhere in WCF that reports back the sent amount of bytes so far? If so how do I hook up to it?

I'd prferably like to grab the amount of data sent until I initiate the upload, use that as start number, then with each increment of bytes sent (something like max WCF transmit buffer / (byteArray / 100)) have the backgroundworker report to the progressbar and increment the percentage of the progressbar... I understand how to do all this, I have just no clue about a possible buffer in WCF and how to grab its values. Then again there might be an easier way of doing this???

Thanks in advance.


BackgroundWorker problems


In my Windows Form I start a long running BackgroundWorker process and use RunWorkerAsync(). Previously before I put the BackgroundWorker in place the application was all but locked up where I cound not minimize, maximize or bring into focus.

Now with the BackgroundWorker in place the application behaves better, however when I attempt to minimize the application things seems to again lockup the application and the application does not minimize. Maximize works but minimize does not.

What steps can I take to correct this?

BackgroundWorker calling COM api method get "Access Violation" error


My WPF appl need to call methods in a COM object (VC++) to do some work. It works perfectly when I call those methods   from the UI thread. As those calls take a very long time to finish, so I decided to move the interaction with COM to a BackgroundWorker. But I got an exception in one COM methods (Other methods still working fine). The error reads:

Unhandled exception at 0x62a7be37 (msvcr100d.dll) in TestApp.exe: 0xC0000005: Access violation writing location 0x0ab0f000.

The signature of the COM method is:


            DWORD size = some func get the size;

            BYTE* pSrcData = the src data address;

            memcpy((void*) pData, pSrcData, size);   //Error occured on this line


    return S_OK;


How the C# calls the method:


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend