Click here to Skip to main content
15,892,059 members
Home / Discussions / C#
   

C#

 
AnswerRe: SMS APPLICATION Pin
Herboren11-Jul-11 6:25
Herboren11-Jul-11 6:25 
Questionlost connection on WebService Pin
goldsoft10-Jul-11 22:29
goldsoft10-Jul-11 22:29 
AnswerRe: lost connection on WebService Pin
Dave Kreskowiak11-Jul-11 1:05
mveDave Kreskowiak11-Jul-11 1:05 
AnswerRe: lost connection on WebService Pin
DaveAuld11-Jul-11 23:05
professionalDaveAuld11-Jul-11 23:05 
QuestionDelete a File - "File does not exist" Pin
phisco12310-Jul-11 6:44
phisco12310-Jul-11 6:44 
AnswerRe: Delete a File - "File does not exist" Pin
Dr.Walt Fair, PE10-Jul-11 8:49
professionalDr.Walt Fair, PE10-Jul-11 8:49 
AnswerRe: Delete a File - "File does not exist" Pin
Heath Stewart10-Jul-11 16:15
protectorHeath Stewart10-Jul-11 16:15 
GeneralRe: Delete a File - "File does not exist" Pin
Ennis Ray Lynch, Jr.11-Jul-11 5:31
Ennis Ray Lynch, Jr.11-Jul-11 5:31 
GeneralRe: Delete a File - "File does not exist" Pin
Herboren11-Jul-11 5:41
Herboren11-Jul-11 5:41 
GeneralRe: Delete a File - "File does not exist" Pin
phisco12311-Jul-11 7:11
phisco12311-Jul-11 7:11 
QuestionCode Sends Me To A New Page Before Completion Pin
PDTUM10-Jul-11 4:42
PDTUM10-Jul-11 4:42 
AnswerRe: Code Sends Me To A New Page Before Completion Pin
Richard MacCutchan10-Jul-11 5:27
mveRichard MacCutchan10-Jul-11 5:27 
GeneralRe: Code Sends Me To A New Page Before Completion Pin
PDTUM11-Jul-11 4:07
PDTUM11-Jul-11 4:07 
GeneralRe: Code Sends Me To A New Page Before Completion Pin
Richard MacCutchan11-Jul-11 4:55
mveRichard MacCutchan11-Jul-11 4:55 
AnswerRe: Code Sends Me To A New Page Before Completion Pin
BobJanova10-Jul-11 22:17
BobJanova10-Jul-11 22:17 
GeneralRe: Code Sends Me To A New Page Before Completion Pin
PDTUM11-Jul-11 4:11
PDTUM11-Jul-11 4:11 
QuestionControlMessage Pin
Snow White_10-Jul-11 2:13
Snow White_10-Jul-11 2:13 
AnswerRe: ControlMessage PinPopular
Dave Kreskowiak10-Jul-11 3:44
mveDave Kreskowiak10-Jul-11 3:44 
AnswerRe: ControlMessage Pin
thatraja10-Jul-11 9:27
professionalthatraja10-Jul-11 9:27 
Questionunblock some item in form Pin
abdellah ab9-Jul-11 8:30
abdellah ab9-Jul-11 8:30 
AnswerRe: unblock some item in form Pin
Heath Stewart9-Jul-11 8:55
protectorHeath Stewart9-Jul-11 8:55 
It would seem you're blocking the UI thread - you're making the UI thread do so much work it can't keep up with all the other requests like to repaint. I assume you're executing this code in response to some control event or initialization code?

While I'm sure this is just an example, assuming there's other work you should do that work in a worker thread and invoke the property setting on the UI thread since many times executing code on a control in a different thread than in which it was created can cause issues.

First you'll need to define a method to set your image property.

private void SetImageLocation(string uri)
{
  if (pictureBox1.InvokeRequired)
  {
    Action<string> setImageLocation = SetImageLocation;
    pictureBox1.Invoke(setImageLocation, new object[] { uri });
  }
  else
  {
    pictureBox1.ImageLocation = uri;
  }
}


To create a worker thread, consider using the ThreadPool like so:

private void DoWork()
{
  for (int i = 0; i < 20000; ++i)
  {
    if (i == 5000)
    {
      SetImageLocation("x.gif");
    }
  }
}

// Assumes you're executing work in response to a Button.Click event.
private void button1_Click(object sender, EventArgs e)
{
  ThreadPool.QueueUserWorkItem(DoWork);
}

This posting is provided "AS IS" with no warranties, and confers no rights.

Program Manager II
Visual Studio Professional Deployment Experience
Microsoft

[My Articles] [My Blog]

AnswerRe: unblock some item in form Pin
DaveAuld9-Jul-11 9:05
professionalDaveAuld9-Jul-11 9:05 
AnswerRe: unblock some item in form Pin
Dr.Walt Fair, PE9-Jul-11 10:38
professionalDr.Walt Fair, PE9-Jul-11 10:38 
GeneralRe: unblock some item in form Pin
BobJanova10-Jul-11 22:19
BobJanova10-Jul-11 22:19 
GeneralRe: unblock some item in form Pin
DaveAuld11-Jul-11 2:47
professionalDaveAuld11-Jul-11 2:47 

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.