Click here to Skip to main content
15,887,434 members
Home / Discussions / C#
   

C#

 
QuestionDifferent Source Codes Pin
nosferatu20009-Nov-05 19:23
nosferatu20009-Nov-05 19:23 
AnswerRe: Different Source Codes Pin
Luis Alonso Ramos9-Nov-05 19:35
Luis Alonso Ramos9-Nov-05 19:35 
QuestionMaskedTextBox Problem ! Pin
Caio19859-Nov-05 17:42
Caio19859-Nov-05 17:42 
GeneralRe: MaskedTextBox Problem ! Pin
Heath Stewart9-Nov-05 22:11
protectorHeath Stewart9-Nov-05 22:11 
QuestionRetrieving an image data type Pin
SyedZubair9-Nov-05 17:39
SyedZubair9-Nov-05 17:39 
AnswerRe: Retrieving an image data type Pin
Heath Stewart9-Nov-05 21:59
protectorHeath Stewart9-Nov-05 21:59 
QuestionException-When minimized and restored Pin
cloudking119669-Nov-05 17:34
cloudking119669-Nov-05 17:34 
AnswerRe: Exception-When minimized and restored Pin
Heath Stewart9-Nov-05 22:09
protectorHeath Stewart9-Nov-05 22:09 
All interaction with a control should be done on the thread on which the control was created. The Control.InvokeRequired property and the Control.Invoke method are for this very thing. You could load the image in a separate thread, but when you assign the image to a PictureBox, for example, you should do it in the control's owner thread:
void AssignImage(Image img)
{
  if (!pictureBox1.InvokeRequired)
  {
    pictureBox1.Image = img;
  }
  else
  {
    MethodInfo setMethod = pictureBox1.GetType().GetProperty("Image").GetSetMethod();
    MethodInfoInvokeHandler d = new MethodInfoInvokeHandler(setMethod.Invoke);
    pictureBox1.Invoke(d, new object[] {pictureBox1, new object[] {img}});
  }
}
delegate object MethodInfoInvokeHandler(object obj, object[] parameters);
Interacting with a control from a different thread causes unusual problems that differ from control to control and even between properties and methods for a single control.

I'm not 100% sure this is the problem you're seeing but it's one possibility.

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

Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft

[My Articles] [My Blog]
AnswerRe: Exception-When minimized and restored Pin
S. Senthil Kumar10-Nov-05 4:19
S. Senthil Kumar10-Nov-05 4:19 
QuestionClass that can read/modify private values of another class Pin
budidharma9-Nov-05 11:30
budidharma9-Nov-05 11:30 
AnswerRe: Class that can read/modify private values of another class Pin
Leslie Sanford9-Nov-05 11:50
Leslie Sanford9-Nov-05 11:50 
GeneralRe: Class that can read/modify private values of another class Pin
budidharma9-Nov-05 12:17
budidharma9-Nov-05 12:17 
GeneralRe: Class that can read/modify private values of another class Pin
Leslie Sanford9-Nov-05 12:21
Leslie Sanford9-Nov-05 12:21 
GeneralRe: Class that can read/modify private values of another class Pin
budidharma9-Nov-05 13:14
budidharma9-Nov-05 13:14 
GeneralRe: Class that can read/modify private values of another class Pin
Leslie Sanford9-Nov-05 15:19
Leslie Sanford9-Nov-05 15:19 
QuestionHow do i create a link to a web page? Pin
Anthony Mushrow9-Nov-05 10:07
professionalAnthony Mushrow9-Nov-05 10:07 
AnswerRe: How do i create a link to a web page? Pin
Matt Gerrans9-Nov-05 11:32
Matt Gerrans9-Nov-05 11:32 
GeneralRe: How do i create a link to a web page? Pin
Anthony Mushrow9-Nov-05 12:22
professionalAnthony Mushrow9-Nov-05 12:22 
QuestionRe: How do i create a link to a web page? Pin
Anthony Mushrow9-Nov-05 12:42
professionalAnthony Mushrow9-Nov-05 12:42 
AnswerRe: How do i create a link to a web page? Pin
Luis Alonso Ramos9-Nov-05 13:15
Luis Alonso Ramos9-Nov-05 13:15 
GeneralRe: How do i create a link to a web page? Pin
Matt Gerrans9-Nov-05 15:59
Matt Gerrans9-Nov-05 15:59 
GeneralRe: How do i create a link to a web page? Pin
Luis Alonso Ramos9-Nov-05 19:28
Luis Alonso Ramos9-Nov-05 19:28 
QuestionCan a C# class be made aware as soon as its instance goes out of function scope? Pin
chervu9-Nov-05 9:32
chervu9-Nov-05 9:32 
AnswerRe: Can a C# class be made aware as soon as its instance goes out of function scope? Pin
Daniel Turini9-Nov-05 10:07
Daniel Turini9-Nov-05 10:07 
QuestionOverloading the assignment operator Pin
budidharma9-Nov-05 9:12
budidharma9-Nov-05 9:12 

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.