Tag Archives: Asad Siddiqi

Remote Software Update Techniques ?

I have worked on various Self Service terminal applications so far . Kiosks for bill payment , Mini statement and balance inquiries and permit printing to self checkout solutions . One requirement that I always come across and I am not absolutely sure how and what would be the better way of solving it is remotely updating software . I want my exes and dlls to be updated and who does it ? Well it can be a windows service or any other application or perhaps a separate thread watching for the updates .

I have some experience with Microsft BITS and i wrote a wrapper for BITS in C# but all i could use the wrapper for was basically file transfer . The object didnt expose some of the core methodologies that Micrsoft uses to update windows or to install windows updates …..

So if you have worked with any such scenario where software can remotely update itself or u have a design in mind do feel free to discuss . I can provide the code whatever i have experimented , but i would really appreciate any ideas / logics or implementation that could help me make a better design for these kind of problems that i often run into … The Software/Configurations Remote update !! If u have the idea and not the time or patience to develope it feel free !! I will develope it for u !! 😀

If you have any experience with making installation patches without hurting the installe application . I have tried Orca editor and the msp files , thats a pain a pain in the back side …. can u think of a smarter way ? Should we write a software which does that ? If you deploy software on a regular basis i m sure you probably might have some idea for a possible work around , I am amazaed why theres nothing from microsoft , doesnt sound that complicated :$

Cheers !!

1 Comment

Filed under Software Design

Responsive User Interfaces with UI Threads

Have you ever seen this exception and wondered “Huh !! wtf is that suppose to mean ?”

exception.jpg

Cross-thread operation not valid: Control ‘Form1’ accessed from a thread other than the thread it was created on.”?? Or you want to update a UI of a windows based application in real time. The classis scenario for this is the stock market applications or processing credit cards from windows based application or while making web service calls synchronously where at many places the real time updates to the UI is absolutely essential.As an application developer / designer you might have encountered situations where The UI of the application gets updated After a COM Component Call or a Web service call or some extensive processing with the data. If this takes too long the User Interface of your application stops responding and hangs which is the first thing people notice and criticize in spite of the efficient code you have written in the business logic for processing complex data !! One possible solution of handling all such scenarios is to update the UI of your Application from a separate thread. The thread would be responsible to update any UI on your forms and another thread would be processing the data simultaneously.I had this idea and when I tried to access windows controls from the newly created thread I had the exception which I have mentioned. I did some research on this and realized that “A control cannot be accessed from any other thread but the thread they were created on “. So for accessing UI elements from a different thread I have made a small framework which you can also use..Net provides a mechanism for this and it’s extremely simple. I think in the upcoming versions of .Net the background worker control would be more powerful and synchronization would be an included feature. So we don’t have to worry about any of it.For now I would just indicate how to update or access the UI from a different thread other than the main Application thread. My sample application is a VC# windows application compiled with .Net 2005 IDE and uses .Net 2 frameworks.I would just give you a step by step description instead of excerpts to make it more easy and understandable.The first thing we need to do is to create a System.Threading.Thread instance. It may be good to make it a form level variable since it might be accessed from different places on your form.ui.jpg

System.Threading.Thread  myThread;In the Constructor or any other suitable place initialize the Thread instance. The constructor is overloaded and I mostly use that takes the ThreadStart instance so I pass a new instance like: 

myThread = new Thread(new ThreadStart(ThreadProc));

 Note: Thread Start is a delegate and requires a target method which it points to and can be called once the thread is running.Now make a no argument method with the same name as you passed in the ThreadStart constructor:
public void ThreadProc()
{

   try
   {

        int count = 0;

        MethodInvoker mi;
        mi= MethodInvoker
(Updater);   

while (globalcount  < 300) 
  
{
         
     this.BeginInvoke(mi);

     Thread.Sleep(500);
         
  }
    
}

catch (Exception ex)    { // do nothing    }

}

We observe that we use another delegate “Method Invoker” which is the key basically. We make an instance of MethodInvoker delegate and pass a no argument method from which we access the UI of the form. After that we call the “BeginInvoke” of our main form and pass the instance of method Invoker.Note: As Method Invoker is also a delegate, we also need to specify the target method. In this case this would be the method from where UI is accessed. 

public void Updater()
{
   this.Text = globalcount.ToString();            
}

Once we are done with all of that all we have to do is to start the thread, so we would just call myThread.Start( ) ,and we are all set up.This way of updating the UI is also efficient in the sense that it is performed asynchronously instead of updating on timers or some other undesirable synchronous way.

 Want more sample code / applications feel free to contact me 🙂 If you have some good design ideas, I would love to hear it!! also post ur comments if there is something specific u r looking for , thanks . If you need examples with C# or java where you wanna update your UI from a different threads I have the code available for you … fell free to discuss here or if this was of any use or not , i would appreciate your feedback !!

My email address is hiasad@hotmail.com

18 Comments

Filed under C#

=) The most beautiful song

This is certainly one of my all time favourite songs , I like the Mark Chestnutt version way better than than Aerosmith’s Steven Tyeler :S hehehe he tries way 222222 hard and does some strange things with his fingers which my jaan finds so hilarious hahahaha !!! Anyways my jaan this is 4 u and it makes me think about yu !! And i Love yu !! heheheh =)

I could stay awake just to hear you breathing
Watch you smile while you are sleeping
While youre far away dreaming
I could spend my life in this sweet surrender
I could stay lost in this moment forever
Every moment spent with you is a moment I treasure

Dont want to close my eyes
I dont want to fall asleep
Cause Id miss you baby
And I dont want to miss a thing
Cause even when I dream of you
The sweetest dream will never do
Id still miss you baby
And I dont want to miss a thing

Lying close to you feeling your heart beating
And Im wondering what youre dreaming
Wondering if its me youre seeing
Then I kiss your eyes
And thank God were together
I just want to stay with you in this moment forever
Forever and ever

Dont want to close my eyes
I dont want to fall asleep
Cause Id miss you baby
And I dont want to miss a thing
Cause even when I dream of you
The sweetest dream will never do
Id still miss you baby
And I dont want to miss a thing

I dont want to miss one smile
I dont want to miss one kiss
I just want to be with you
Right here with you, just like this
I just want to hold you close
Feel your heart so close to mine
And just stay here in this moment
For all the rest of time

Dont want to close my eyes
I dont want to fall asleep
Cause Id miss you baby
And I dont want to miss a thing
Cause even when I dream of you
The sweetest dream will never do
Id still miss you baby
And I dont want to miss a thing

Leave a comment

Filed under 1