Click here to Skip to main content
15,889,992 members
Home / Discussions / C#
   

C#

 
GeneralRe: Avoid having more than 5 arguments in the Method:'{0}' Pin
sarvesh.upadhyay16-Apr-08 1:42
professionalsarvesh.upadhyay16-Apr-08 1:42 
GeneralRe: Avoid having more than 5 arguments in the Method:'{0}' Pin
PIEBALDconsult16-Apr-08 4:00
mvePIEBALDconsult16-Apr-08 4:00 
QuestionInstall C# Without Administrative Rights Pin
joie717015-Apr-08 20:35
joie717015-Apr-08 20:35 
GeneralRe: Install C# Without Administrative Rights Pin
Christian Graus15-Apr-08 21:02
protectorChristian Graus15-Apr-08 21:02 
GeneralRe: Install C# Without Administrative Rights Pin
Expert Coming15-Apr-08 22:55
Expert Coming15-Apr-08 22:55 
GeneralRe: Install C# Without Administrative Rights Pin
Dave Kreskowiak16-Apr-08 4:23
mveDave Kreskowiak16-Apr-08 4:23 
GeneralRe: Install C# Without Administrative Rights Pin
joie717016-Apr-08 16:53
joie717016-Apr-08 16:53 
GeneralThreading problem in C# [modified] Pin
mihai12315-Apr-08 20:18
mihai12315-Apr-08 20:18 
Hello,
I have a weird problem with my c# code. It works fine on my pc sempron 1600+ but it cracks on dual core processors.

I have two classes (the main form, and one that implements some change to an image). I want to show the change in real time on the form on a picture box. So I created a thread and use delegates and beginInvoke method to refresh the pictureBox after I changed some pixels of the image that I display there.

The application works fine on low speed processors but on dual core or processor with 2ghz+ it cracks, it put the processor on 100% and does not make any changes to the pictureBox. Also I putted some breakpoints and I was stupefied, the application enters the section that changed the pixels, enters the delegate function that refresh the panel but it doesn't make any changes... I have not clue what I done wrong.

Note: I tried the Invoke method too but it the same problem.

I'm open to any suggestions

Thanks

Edit add some code
The delegates
<br />
      public delegate void DelegatePictureBoxUpdate();<br />
      public delegate void DelegatePictureBoxLoad(Bitmap image, int nr);<br />
      public delegate void DelegateActualizareStatus();<br />
      public delegate void DelegateActualizareFinal();<br />
<br />
      Thread fir;<br />
		// events used to stop worker thread<br />
	ManualResetEvent m_EventStopThread;<br />
	ManualResetEvent m_EventThreadStopped;<br />
<br />
	// Delegate instances used to cal user interface functions <br />
	// from worker thread:<br />
        public DelegatePictureBoxUpdate m_DelegatePictureBoxUpdate;<br />
        public DelegatePictureBoxLoad m_DelegatePictureBoxLoad;<br />
        public DelegateActualizareStatus m_DelegateStatus;<br />
	public DelegateActualizareFinal m_DelegateFinal;<br />
<br />

The delegate function that loads and refresh the pctBox
	<br />
 public void LoadPictureBox(Bitmap final, int nr)<br />
        {<br />
        	progressInpaint.Maximum=nr;<br />
			progressInpaint.Step= nr/20;<br />
            pctBoxReparat.Image=final;<br />
            lblProprietati.Enabled=true;<br />
            lblProprietati.Text+=":"+nr.ToString();<br />
        }<br />
 public void UpdateStatus()<br />
        {<br />
            progressInpaint.Value+=progressInpaint.Step;<br />
            progressInpaint.Refresh();<br />
        }<br />
<br />
//the form close event<br />
void MainFormFormClosed(object sender, FormClosedEventArgs e)<br />
		{<br />
			<br />
			if ( fir!= null  &&  fir.IsAlive )  // thread is active<br />
			{<br />
				// set event "Stop"<br />
				m_EventStopThread.Set();<br />
<br />
				// wait when thread  will stop or finish<br />
				while (fir.IsAlive)<br />
				{<br />
					// We cannot use here infinite wait because our thread<br />
					// makes syncronous calls to main form, this will cause deadlock.<br />
					// Instead of this we wait for event some appropriate time<br />
					// (and by the way give time to worker thread) and<br />
					// process events. These events may contain Invoke calls.<br />
					if ( WaitHandle.WaitAll(<br />
						(new ManualResetEvent[] {m_EventThreadStopped}), <br />
						100,<br />
						true) )<br />
					{<br />
						break;<br />
					}<br />
<br />
					Application.DoEvents();<br />
				}<br />
			}<br />
		}<br />


The code in the other class:

 <br />
//load the picture in the pctBox the image appears on the PctBox but after this nothing happend<br />
m_form.BeginInvoke(m_form.m_DelegatePictureBoxLoad, new Object[] {final, nrPuncteDeterioate});<br />
			<br />
//change some pixel and then <br />
<br />
m_form.BeginInvoke(m_form.m_DelegatePictureBoxUpdate,null);<br />
<br />
//at the end of the opperation<br />
m_EventStopped.Set();<br />


modified on Wednesday, April 16, 2008 3:45 AM

GeneralRe: Threading problem in C# Pin
Zoltan Balazs15-Apr-08 21:22
Zoltan Balazs15-Apr-08 21:22 
GeneralPass the text box value from one form to other Pin
sjs4u15-Apr-08 19:27
sjs4u15-Apr-08 19:27 
GeneralRe: Pass the text box value from one form to other Pin
Zoltan Balazs15-Apr-08 19:41
Zoltan Balazs15-Apr-08 19:41 
GeneralRe: Pass the text box value from one form to other Pin
Razvan Dimescu15-Apr-08 19:45
Razvan Dimescu15-Apr-08 19:45 
GeneralRe: Pass the text box value from one form to other Pin
Christian Graus15-Apr-08 19:46
protectorChristian Graus15-Apr-08 19:46 
GeneralRe: Pass the text box value from one form to other Pin
sarvesh.upadhyay16-Apr-08 1:37
professionalsarvesh.upadhyay16-Apr-08 1:37 
GeneralRe: Pass the text box value from one form to other Pin
sjs4u16-Apr-08 2:24
sjs4u16-Apr-08 2:24 
QuestionHow to create array textbox in design time Pin
cocoonwls15-Apr-08 19:02
cocoonwls15-Apr-08 19:02 
AnswerRe: How to create array textbox in design time Pin
Christian Graus15-Apr-08 19:47
protectorChristian Graus15-Apr-08 19:47 
GeneralRe: How to create array textbox in design time Pin
dan!sh 15-Apr-08 20:28
professional dan!sh 15-Apr-08 20:28 
GeneralRe: How to create array textbox in design time Pin
cocoonwls15-Apr-08 22:10
cocoonwls15-Apr-08 22:10 
GeneralRe: How to create array textbox in design time Pin
Christian Graus16-Apr-08 11:20
protectorChristian Graus16-Apr-08 11:20 
GeneralRe: How to create array textbox in design time Pin
cocoonwls16-Apr-08 16:27
cocoonwls16-Apr-08 16:27 
GeneralSample XNA solutions with .tga files. Pin
NarVish15-Apr-08 18:42
NarVish15-Apr-08 18:42 
GeneralRe: Sample XNA solutions with .tga files. Pin
MarkB77715-Apr-08 18:59
MarkB77715-Apr-08 18:59 
QuestionThread communication & Other RTOS concepts Pin
tvis15-Apr-08 17:38
tvis15-Apr-08 17:38 
GeneralRe: Thread communication & Other RTOS concepts Pin
Zoltan Balazs15-Apr-08 19:48
Zoltan Balazs15-Apr-08 19:48 

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.