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 7825041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:48:47+00:00 2026-06-02T08:48:47+00:00

I have a SL application that is running in a browser. The user presses

  • 0

I have a SL application that is running in a browser. The user presses a button and a OpenFiledDialog is shown. When the user has selected a file, I want to do some processing on it. However, I also want to show a progress bar and enable the user to cancle the operation.

My code:

var dialog = new OpenFileDoalog { Filter = ... };

if(dialog.ShowDialog() != true)
    return;

// Show the Progress bar
MyProgressBar.Visibility = System.Windows.Visibility.Visible;

// Do the processing on another thread
new Thread(() =>
{   
    var stream = dialog.File.OpenRead();
    var data = Process(stream);
    Dispatcher.BeginInvoke(() => IGotSomeDataForYou(data));
}).Start();

However, I get an InvalidOperationException on FileInfo.OpenRead() because This operation can only occur on the UI Thread..

However, if I do the work on the UI thread, the UI freezes as long as the processing is being done. And I cannot open the stream on the UI thread and then process it on the background thread, because that gives an error on cross-thread usage.

I would think this is a common problem but I failed to find a solution. What are my options in this case? Read it to a in-memory byte array first and then provess it? Anything else?

Thanks!

  • 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-02T08:48:52+00:00Added an answer on June 2, 2026 at 8:48 am

    Don’t call dialog.File.OpenRead(); in a separate thread. Call it on UI thread them get file returned from opendialog and set it to a private property and then process it on a background thread e.g upload it.

    OpenFileDialog has some limitations in SL. check out my question for more details. Dialogs must be user-initiated. Silverlight

    Regards.

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

Sidebar

Related Questions

We have an application that has a WCF service (*.svc) running on IIS7 and
I have an NSTimer running in my application that collects some data and sends
We have a Silverlight application that runs OOB (out of browser) so the user
We have an ASP.NET application that queues some of its long-running operations (generating reports,
I have created a Silverlight 4 application, that is running out of browser. As
So I have an iPhone application running that is controlled at the highest level
I have a thread in my application that is running code that can potentially
We have a asp.net 2.0 web application that is running on IIS7. It is
I have a .NET 2.0 targeted C# windows forms application that is running fine
I have an application running under WebLogic that is using standard forms authentication. The

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.