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

Autorefresh lightswitch screen in lightswitch 2011




















Software requirement











Prerequisite knowledge













Creation of new project





Click to Enlarge


Add Employee entity in the project





Click to Enlarge


Add Editable grid screen





Click to Enlarge


Add records in the table





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