[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

11/06/2009 at 01:29AM PST, ID: 24877367 | Points: 500
[x]
Attachment Details

cross thread access

Asked by jagguy in WPF and Silverlight, C# Programming Language

Hi,

I am getting a cross thread access error, when loading an image in a background thread in silverlight

How do i fix this?



Private Sub bw_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)


     Dim bw As BackgroundWorker = New BackgroundWorker
     
 AddHandler bw.DoWork, AddressOf bw_DoWork
      ...
        For i = 1 To 10
            System.Threading.Thread.Sleep(500)
            bw.ReportProgress(i * 10)
            a.X = i
            a.Y = i
            e.Result = "l"
        Next

        img = New Image
        _x = 100
        _y = 300
        url = New Uri("images/circle.png", UriKind.Relative)
        uu = New BitmapImage(url)
        uu.UriSource = url
        img.Source = uu
        Canvas.SetLeft(img, _x)
        Canvas.SetTop(img, _y)
        Canvas.SetZIndex(img, 10)
        canvas1.Children.Add(img)
        AddHandler uu.ImageOpened, AddressOf uu_downloadComplete

    End Sub
 
[+][-]11/06/09 02:54 AM, ID: 25758058

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/07/09 02:29 AM, ID: 25765724

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/07/09 04:03 AM, ID: 25765944

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/07/09 05:34 AM, ID: 25766262

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/07/09 01:15 PM, ID: 25768088

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/08/09 02:26 PM, ID: 25772270

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/11/09 11:25 AM, ID: 25798111

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/16/09 08:09 AM, ID: 25831297

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/16/09 08:14 AM, ID: 25831341

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20090824-EE-VQP-74 - Hierarchy / EE_QW_3_20080625