c# second form loaded form class issue

  • Thread starter Thread starter elfenliedtopfan2
  • Start date Start date
E

elfenliedtopfan2

Guest
ok i have a dll file that has a lot of classes in it ( reason for this people keep stealing my code for some reason when you load a dll into a .net decompliler it scrambles it but not the point i have a form loaded and i downloading files what i want is after each file download the process shuts down and starts up again when new one is triggered


this is the code i have for the download

WebClient cliant;

private void Process_Load(object sender, EventArgs e)
{
cliant = new WebClient();
cliant.DownloadProgressChanged += Cliant_DownloadProgressChanged;
cliant.DownloadFileCompleted += Cliant_DownloadFileCompleted;
labelControl2.Text = "Currently Downloading" + Sachiko_Res.Name;
download();
// this.Close();
}

private void Cliant_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
}

private void Cliant_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{

Invoke(new MethodInvoker(delegate ()
{
progressBarControl1.Properties.Minimum = 0;
double receive = double.Parse(e.BytesReceived.ToString());
double total = double.Parse(e.TotalBytesToReceive.ToString());
double precentage = receive / total * 100;
labelControl1.Text = $"Downloaded {string.Format("{0:0.##}", precentage)}%";
progressBarControl1.PerformStep();
progressBarControl1.Properties.Step = int.Parse(Math.Truncate(precentage).ToString());

}));
}

public void download()
{
string url = Sachiko_Res.Url;
if (!string.IsNullOrEmpty(url))
{
Thread thread = new Thread(() =>
{
Uri uri = new Uri(url);
string filename = Sachiko_Res.Name;
cliant.DownloadFileAsync(uri, Sachiko_Res.elfenliedprogsettings.Read("DOWNLOADPATH") + "//_images" + "/" + filename);

});
thread.Start();
}
}


and i call it form a class when in and show the form like this

Process elfform = new Process()

elfform.Show()

but it cycels throw the downloads and i have to hit the exit button on each form they stack up on each download i want the forms to load when hits 100 second form closes when i get to download funtion again another one will load up ect


this is a image of what it does.

Idtk4R4.png


thanks in advance elfenliedtopfan5

Continue reading...
 
Back
Top