Click here to Skip to main content
15,899,025 members
Home / Discussions / C#
   

C#

 
GeneralRe: VS 2005 Remoting Pin
Judah Gabriel Himango17-Apr-07 4:51
sponsorJudah Gabriel Himango17-Apr-07 4:51 
QuestionProgress bar Issue Pin
sujithkumarsl15-Apr-07 21:47
sujithkumarsl15-Apr-07 21:47 
AnswerRe: Progress bar Issue Pin
Christian Graus15-Apr-07 21:52
protectorChristian Graus15-Apr-07 21:52 
GeneralRe: Progress bar Issue Pin
sujithkumarsl15-Apr-07 22:17
sujithkumarsl15-Apr-07 22:17 
GeneralRe: Progress bar Issue Pin
Christian Graus15-Apr-07 22:45
protectorChristian Graus15-Apr-07 22:45 
GeneralRe: Progress bar Issue Pin
sujithkumarsl15-Apr-07 23:17
sujithkumarsl15-Apr-07 23:17 
GeneralRe: Progress bar Issue Pin
Christian Graus15-Apr-07 23:27
protectorChristian Graus15-Apr-07 23:27 
Questionthread is blocking the gui form, why? Pin
Krzysztof Gorgolewski15-Apr-07 21:29
Krzysztof Gorgolewski15-Apr-07 21:29 
hi,

i'm having a silly problem and i'm trying to describe it as simple as possible Smile | :)

i'm accessing a device which takes images. this device has a timeout property, which i have to set high (for some seconds). if a timeout occurs, it is "catched". after an image is taken, it is shown in my gui window.

so, i put the device accessing part in a thread which is getting the images and sending the images to the gui. in code it looks like this:

public delegate void newimg_handler(object sender, newimage_args e);

public class camerathread
{
	public event newimg_handler newimg;

	bool quitthread;

	imageobject img;

	public camerathread()
	{
		img = new imageobject();
		quitthread = false;

		OpenImageDevice();

	}

	public void exithread()
	{
		quitthread = true;
	}

	public void run()
	{
		while (!quitthread)
		{
			try
			{
				GetImage(out img);
				if(newimg != null)
				{
					newimage_args nia = new newimage_args();
						nia.img = img;
						newimg(this, nia);
				}
			}
			catch
			{
			}
		}
	}

}

public class newimage_args : EventArgs
{
	public imageobject img;

	public newimage_args()
	{
	}
}


and in the main form it's called like this:

public Form1()
{
...
	ct = new camerathread();
	ct.newimg += new newimg_handler(ct_newimg);
	camerawork = new System.Threading.Thread(new System.Threading.ThreadStart(ct.run));
	camerawork.Priority = System.Threading.ThreadPriority.AboveNormal;
	camerawork.Start();
...
}

void ct_newimg(object sender, newimage_args e)
{
	img = e.img;
	display(img);
}


my BIG problem is, that the gui form is not responding while the thread is waiting for an image from the device (it can be many seconds, according to the timeout property). but why? i wrote the same application in c++ and everything is working fine (but c++ is at the moment not an option, the application has to be in c#.net). i also tried asynchron BeginInvoke calls on a method which is taking the images, but the same result. it looks like it's working sequentially, like i would use a timer for getting the images.

how can i make the thread completely independent working from the gui form, so i can also interact with the gui? i'm confused about the threading under .net. any hint is welcome. help


regards,

criss
AnswerRe: thread is blocking the gui form, why? Pin
Christian Graus15-Apr-07 21:51
protectorChristian Graus15-Apr-07 21:51 
GeneralRe: thread is blocking the gui form, why? Pin
Krzysztof Gorgolewski15-Apr-07 22:05
Krzysztof Gorgolewski15-Apr-07 22:05 
GeneralRe: thread is blocking the gui form, why? Pin
Christian Graus15-Apr-07 22:46
protectorChristian Graus15-Apr-07 22:46 
AnswerRe: thread is blocking the gui form, why? Pin
Luc Pattyn15-Apr-07 21:52
sitebuilderLuc Pattyn15-Apr-07 21:52 
GeneralRe: thread is blocking the gui form, why? Pin
Krzysztof Gorgolewski15-Apr-07 22:15
Krzysztof Gorgolewski15-Apr-07 22:15 
GeneralRe: thread is blocking the gui form, why? Pin
Luc Pattyn15-Apr-07 22:27
sitebuilderLuc Pattyn15-Apr-07 22:27 
GeneralRe: thread is blocking the gui form, why? Pin
Guffa15-Apr-07 22:32
Guffa15-Apr-07 22:32 
GeneralRe: thread is blocking the gui form, why? [modified] Pin
Krzysztof Gorgolewski15-Apr-07 22:45
Krzysztof Gorgolewski15-Apr-07 22:45 
AnswerRe: thread is blocking the gui form, why? Pin
Guffa16-Apr-07 0:38
Guffa16-Apr-07 0:38 
GeneralRe: thread is blocking the gui form, why? Pin
Krzysztof Gorgolewski16-Apr-07 1:12
Krzysztof Gorgolewski16-Apr-07 1:12 
AnswerRe: thread is blocking the gui form, why? Pin
Martin#15-Apr-07 21:55
Martin#15-Apr-07 21:55 
GeneralRe: thread is blocking the gui form, why? Pin
Krzysztof Gorgolewski15-Apr-07 22:20
Krzysztof Gorgolewski15-Apr-07 22:20 
GeneralRe: thread is blocking the gui form, why? Pin
Martin#15-Apr-07 22:36
Martin#15-Apr-07 22:36 
Answerthanks to all Pin
Krzysztof Gorgolewski16-Apr-07 4:57
Krzysztof Gorgolewski16-Apr-07 4:57 
Questionxpath Vs xml validation with xsd Pin
praveenkumar palla15-Apr-07 21:05
praveenkumar palla15-Apr-07 21:05 
AnswerRe: xpath Vs xml validation with xsd Pin
Stefan Troschuetz15-Apr-07 21:10
Stefan Troschuetz15-Apr-07 21:10 
GeneralRe: xpath Vs xml validation with xsd Pin
praveenkumar palla15-Apr-07 21:23
praveenkumar palla15-Apr-07 21:23 

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.