From: Robert Bevington on
Hi everyone,

I'm trying to set up a backgroundworker so that I can dispaly a progress bar
in marquee mode while a long process (external API call) is running.

Public Sub bgw_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)

ImportDef.ProcessImport(MtTaskType.mtScript)

End Sub

My problem is getting the line that makes the API call ..ProcessImport to
work. I keep getting
the following error meesage when I call the API method:

Object reference not set to an instance of an object.

Has this got anything to do with the object being initially created outside
the background worker? If so, how do I pass this object to the
backgroundworker?

Thanks for any help

Robert



From: Patrice on
Check ImportDef and MtTaskType.mtScript to see if they are valid (i.e. not
nothing). This error message means that an object variable is not
initialized (i.e. is "nothing").

--
Patrice


"Robert Bevington" <rbevington(a)dspace.de> a �crit dans le message de
news:u%23EDkZlgKHA.1536(a)TK2MSFTNGP06.phx.gbl...
> Hi everyone,
>
> I'm trying to set up a backgroundworker so that I can dispaly a progress
> bar
> in marquee mode while a long process (external API call) is running.
>
> Public Sub bgw_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
>
> ImportDef.ProcessImport(MtTaskType.mtScript)
>
> End Sub
>
> My problem is getting the line that makes the API call ..ProcessImport to
> work. I keep getting
> the following error meesage when I call the API method:
>
> Object reference not set to an instance of an object.
>
> Has this got anything to do with the object being initially created
> outside
> the background worker? If so, how do I pass this object to the
> backgroundworker?
>
> Thanks for any help
>
> Robert
>
>
>

From: Patrice on
My guess would be that you defined them both outside of the form (where they
work) and inside your form where you would use then those other unitializeed
variable.

Strip down your code to the minimal amount of code that shows the problem
and you'll likely find the cullprit. If not you'll have the shortest
possible amount of code to post so that others can give a look and hpefully
find the issue.

--
Patrice


"Robert Bevington" <rbevington(a)dspace.de> a �crit dans le message de
news:eMVPR1tgKHA.1460(a)TK2MSFTNGP06.phx.gbl...
> Hi Patrice,
>
> yes they are both nothing inside the Backgroundwork.DoWork method. Outside
> of this Method they work fine. And that's exactly my problem. I defined
> the objects as public, but that does not seem to help. That's why I
> thought it had something to do with separate threads. I read something on
> delegates, but couldn't really get my head round it. Could that be the
> solution?