Articles → LIGHT SWITCH 2011 → Autorefresh lightswitch screen in lightswitch 2011

Autorefresh lightswitch screen in lightswitch 2011




















Software requirement











Prerequisite knowledge













Creation of new project




Picture showing the project structure of the lightswitch project

Click to Enlarge


Add Employee entity in the project




Picture showing the schema of Employee table in lightswitch

Click to Enlarge


Add Editable grid screen




Picture showing the editable grid screen added in the project

Click to Enlarge


Add records in the table




Picture showing records added in the lightswitch project

Click to Enlarge


Add timer in the screen




using System;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using System.Windows.Threading;
using Microsoft.LightSwitch.Threading;

namespace LightSwitchApplication {
	public partial class EditableEmployeesSetGrid {
		partial void EditableEmployeesSetGrid_InitializeDataWorkspace(List < IDataService > saveChangesTo) {
			Dispatchers.Main.BeginInvoke(() = >{
				Timer.Tick += new EventHandler(Each_Tick);
				Timer.Start();
			});

		}

		private static readonly DispatcherTimer Timer = new DispatcherTimer() {
			Interval = TimeSpan.FromSeconds(5) // Create a timer to refresh screen
		};

		private void Each_Tick(object sender, EventArgs e) {
			Dispatchers.Main.BeginInvoke(() = >{
				EmployeesSet.Refresh();
			});
		}
	}
}







Posted By  -  Ritesh Arya
 
Posted On  -  Wednesday, September 19, 2012

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250