Click here to Skip to main content
15,914,481 members
Home / Discussions / C#
   

C#

 
AnswerRe: how can i add checkbox to datagrid Pin
Nader Elshehabi8-Oct-06 6:28
Nader Elshehabi8-Oct-06 6:28 
Questionpublic static property question Pin
uglyeyes7-Oct-06 20:55
uglyeyes7-Oct-06 20:55 
AnswerRe: public static property question Pin
NaNg152417-Oct-06 21:00
NaNg152417-Oct-06 21:00 
AnswerRe: public static property question Pin
Guffa7-Oct-06 21:12
Guffa7-Oct-06 21:12 
GeneralRe: public static property question Pin
Christian Graus8-Oct-06 0:27
protectorChristian Graus8-Oct-06 0:27 
QuestionWireless with C# on WindowsXP ?? Pin
allenmpcx7-Oct-06 20:30
allenmpcx7-Oct-06 20:30 
AnswerRe: Wireless with C# on WindowsXP ?? Pin
yoaz7-Oct-06 22:09
yoaz7-Oct-06 22:09 
QuestionBackgroundWorker ? Pin
Christian Graus7-Oct-06 17:31
protectorChristian Graus7-Oct-06 17:31 
I've set up a background worker thread to load images from a web service, but while it does that, my program becomes unresponsive. I call the method to load the image in my DoWork delegate, doesn't that mean it happens on the other thread ? I also had a progresschanged delegate, it just sets a position in a progress bar. With this in, it died right away. I took it out and it seemed to work, but when I gave the program focus, it immediately became unresponsive. In both cases, it's Not Responding in the Task Manager, and the UI no longer responds to any events. I'm running a debug version, in the IDE, when I break, it's always on the line in the other thread that loads an image from the web service. The main thread is not doing any work of any kind, in theory.

What might I be missing here ?

threadLoadCase = new BackgroundWorker();
threadLoadCase.DoWork += new DoWorkEventHandler(threadLoadCase_DoWork);
threadLoadCase.ProgressChanged += new ProgressChangedEventHandler(threadLoadCase_ProgressChanged);
threadLoadCase.WorkerReportsProgress = true;
threadLoadCase.RunWorkerCompleted += new RunWorkerCompletedEventHandler(threadLoadCase_RunWorkerCompleted);


void threadLoadCase_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
if (e.UserState != null)
lblLoadingCase.Text = "Downloading " + e.UserState.ToString() + ":";

progressLoading.Value = e.ProgressPercentage;

// Without this, the progress bar never showed at all.
Application.DoEvents();

}

void threadLoadCase_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (!string.IsNullOrEmpty(e.Result.ToString()) && !firstFeedMe)
{
firstFeedMe = true;
filmStrip1.Clear();

OpenFiles(Directory.GetFiles((string)e.Result));

ResetDisplayMode();
}
}

void threadLoadCase_DoWork(object sender, DoWorkEventArgs e)
{
lblLoadingCase.Visible = progressLoading.Visible = true;
Application.DoEvents();
progressLoading.Value = 0;
e.Result = LoadCase(RequestIDs[0]);
}

and the guts of the method:

ImageInfo[] images = inbox.GetRequestImages(req.IdRequest);

int percentstep = 100 / (images.Length + 1);
int percent = percentstep;

foreach (ImageInfo inf in images)
{
// threadLoadCase.ReportProgress(percent, req.PatientName + req.OwnerLastName);

string imageFile = Path.Combine(folder, inf.ItemName);

if (!File.Exists(imageFile))
{
ImageData data = inbox.GetImageCompressed(inf.IdImage, dicomCompressionTypes.cmpJPEG2000);

using (FileStream fs = new FileStream(imageFile, FileMode.OpenOrCreate, FileAccess.Write))
{
fs.Write(data.Image, 0, data.Image.Length);
fs.Close();
}
}

percent += percentstep;
}

Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog

AnswerRe: BackgroundWorker ? Pin
Judah Gabriel Himango7-Oct-06 17:47
sponsorJudah Gabriel Himango7-Oct-06 17:47 
GeneralRe: BackgroundWorker ? Pin
Christian Graus7-Oct-06 23:07
protectorChristian Graus7-Oct-06 23:07 
GeneralRe: BackgroundWorker ? Pin
Christian Graus8-Oct-06 0:37
protectorChristian Graus8-Oct-06 0:37 
GeneralRe: BackgroundWorker ? Pin
Judah Gabriel Himango8-Oct-06 8:22
sponsorJudah Gabriel Himango8-Oct-06 8:22 
AnswerRe: BackgroundWorker ? Pin
Robert Rohde7-Oct-06 22:47
Robert Rohde7-Oct-06 22:47 
GeneralRe: BackgroundWorker ? Pin
Christian Graus7-Oct-06 23:09
protectorChristian Graus7-Oct-06 23:09 
QuestionNetwork management with C# .NET? Pin
Asad_N7-Oct-06 17:01
Asad_N7-Oct-06 17:01 
AnswerRe: Network management with C# .NET? Pin
Ray Cassick7-Oct-06 17:09
Ray Cassick7-Oct-06 17:09 
GeneralRe: Network management with C# .NET? Pin
Asad_N7-Oct-06 17:38
Asad_N7-Oct-06 17:38 
AnswerRe: Network management with C# .NET? Pin
yoaz7-Oct-06 22:44
yoaz7-Oct-06 22:44 
AnswerRe: Network management with C# .NET? Pin
spiritboy10-Jul-09 6:59
spiritboy10-Jul-09 6:59 
QuestionEditing a file over FTP Pin
Anthony Mushrow7-Oct-06 15:08
professionalAnthony Mushrow7-Oct-06 15:08 
AnswerRe: Editing a file over FTP Pin
Guffa7-Oct-06 20:39
Guffa7-Oct-06 20:39 
AnswerRe: Editing a file over FTP Pin
Daniel Monzert7-Oct-06 21:27
Daniel Monzert7-Oct-06 21:27 
QuestionUDP/IP sockets Pin
NaNg152417-Oct-06 10:21
NaNg152417-Oct-06 10:21 
QuestionInserting data from datagrid into Sql server Pin
engineer_ali7-Oct-06 7:46
engineer_ali7-Oct-06 7:46 
QuestionHow to print Datagrid in C# 2005 ? Pin
hdv2127-Oct-06 7:37
hdv2127-Oct-06 7:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.