Go Back

Silverlight 2.0 goofin'

I was dreaming about using silverlight in a banking app and threw this 'real time updating' account information app together.

I used the data grid control by Component One

If a company had the right event structure and you used push services like wcf net.tcp or biztalk.net you could do something like this pretty easily ...

 

note: this is not ajax, this is real multi-threading.

 

Here's the relavent sample code:

 

       List<Account> accounts = new List<Account>();

        public Page()

        {

            InitializeComponent();

            this.Loaded += new RoutedEventHandler(Page_Loaded);

        }

 

        void Page_Loaded(object sender, RoutedEventArgs e)

        {

           

            Account account = new Account();

            account.Name="checking";

            account.AvailableBalance=238.87M;

            account.CurrentBalance=242.28M;

            account.AccountNumber="******823";

            accounts.Add(account);

            account = new Account();

            account.Name = "savings";

            account.AvailableBalance = 2000.00M;

            account.CurrentBalance = 2000.00M;

            account.AccountNumber = "******544";

            accounts.Add(account);

            this.AccountsGrid.DataSource = accounts;

           

            System.Threading.Thread myThread = new System.Threading.Thread(DoStuff);

 

            myThread.Start();

 

 

        }

        private void DoStuff()

        {

            while (accounts[1].AvailableBalance > 1)

            {

                System.Threading.Thread.Sleep(100);

                accounts[0].AvailableBalance += 1;

                accounts[1].AvailableBalance -= 1;

                //now dispatch to the original thread to update the UI.

                this.Dispatcher.BeginInvoke(new Action(this.AccountsGrid.EndUpdate));

            }

        }

Facebook DZone It! Digg It! StumbleUpon Technorati Del.icio.us NewsVine Reddit Blinklist Furl it!

Post a comment!
  1. Formatting options