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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:22:25+00:00 2026-06-01T19:22:25+00:00

I divided my programme in 3 layers; GUI, BL, IO and tried to grap

  • 0

I divided my programme in 3 layers; GUI, BL, IO and tried to grap files from my server to my pc. I made it multi threaded and zorks fine, but when i tried to add a delegate to it for sending messages from my IO to my GUI, it troubels me. It said something like:

It is not allowed to perform an operation through various threads: it
was from another thread had access to the control label download
progress than the thread on which the element is created.

What i have is this:

GUI

private void buttonDownload_Click(object sender, EventArgs e)
{
    download = new BL_DataTransfer(Wat.FILM, titel, this.downloadDel);
    t = new Thread(new ThreadStart(download.DownLoadFiles));    
    t.Start();
}
private void UpdateDownloadLabel(string File)
{
        labelDownloadProgress.Text = "Downloading: " + File;
}

BL

    public void DownLoadFiles()
    {
        //bestanden zoeken op server
        string map = BASEDIR + this.wat.ToString() + @"\" + this.titel + @"\";
        string[] files = IO_DataTransfer.GrapFiles(map);

        //pad omvormen
        string[] downloadFiles = this.VeranderNaarDownLoadPad(files,this.titel);
        IO_DataTransfer.DownloadFiles(@".\" + this.titel + @"\", files, downloadFiles, this.obserdelegate);
    }

IO

    public static void DownloadFiles(string map, string[] bestanden, string[] uploadPlaats, ObserverDelegate observerDelegete)
    {
        try
        {
            Directory.CreateDirectory(map);

            for (int i = 0; i < bestanden.Count(); i++)
            {
                observerDelegete(bestanden[i]);
                File.Copy(bestanden[i], uploadPlaats[i]);
            }
        }
        catch (UnauthorizedAccessException uoe) { }
        catch (FileNotFoundException fnfe) { }
        catch (Exception e) { }        
    }

Delgate

 public delegate void ObserverDelegate(string fileName);
  • 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-01T19:22:27+00:00Added an answer on June 1, 2026 at 7:22 pm

    if UpdateDownloadLabel function is in some control code-file, use pattern like this:

    private void UpdateDownloadLabel(string File)
    {
         this.Invoke(new Action(()=> {
                 labelDownloadProgress.Text = "Downloading: " + File;
          })));
    }
    

    You need to invoke assignment on UI thread in order to be able to change something on label.

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

Sidebar

Related Questions

My Django project is divided into several apps, and the static files are stored
I've tried writing a simple application thats supposed to detect pixel differences from the
I'm working on a project about graph-coloring (with GUI). I have a map divided
In the structure of my program I've divided where it gets called from and
I am working on a little multi-threading project.The system could be divided into 2
The following program is a basic linked list divided in 3 classes. In the
I'm currently making a PHP-program that solves equations. I've divided the input equation into
I made small program to divide large pictures and take part of them. When
Im working right now on a program that can divide, add, ect, but, im
I have a project divided into several sub-modules (each of them are jar libraries):

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.