Thread

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
NewMen
Posts: 2
Joined: Fri Nov 09, 2012 4:53 pm

Thread

Post by NewMen »

when I execute the code below appears this error "Object reference not set to an instance of an object" but I do not understand why :roll:

Code: Select all

	
namespace Neo.ApplicationFramework.Generated
{
    using System.Windows.Forms;
    using System;
    using System.Drawing;
    using Neo.ApplicationFramework.Tools;
    using Neo.ApplicationFramework.Common.Graphics.Logic;
    using Neo.ApplicationFramework.Controls;
	using Neo.ApplicationFramework.Interfaces;
	using System.Collections.Generic;
	using System.ComponentModel;
	using System.Data;
	using System.Drawing;
	using System.Linq;
	using System.Text;
	using System.Threading;
	using System.Threading.Tasks; 
    
    
    public partial class Screen1
    {
   		public delegate void MontrerProgres(int valeur);
		Thread t1;
		int i ;
		
		void Button1_Click(System.Object sender, System.EventArgs e)
		{
			AnalogNumeric1.Value=0;
			t1 = new Thread(new ThreadStart(Selection));
			t1.Start();
		}
		public void Selection()
		{
			for (i= 0; i < 10; i++)
			{
				
				Form.ActiveForm.Invoke(new MontrerProgres(changeValue), i);
				Thread.Sleep(1000);
			}
		}
		public void changeValue(int i)
		{
			i = i + 1;
			AnalogNumeric1.Value=i;
           
		}
		
		void Screen1_Opened(System.Object sender, System.EventArgs e)
		{
			
		}
    }
}

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Thread

Post by mark.monroe »

It compiles fine when I target a PC. I get a namspace error when targeting a CE panel. That is because System.Threading.Tasks is not available on a Win CE panel. It is not part of the MS C# libraries for Win CE.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

NewMen
Posts: 2
Joined: Fri Nov 09, 2012 4:53 pm

Re: Thread

Post by NewMen »

It also compiles for me, but when I run the program, the label does not increment and the program sends me an exception :?:

Post Reply