Your problem is that you do lengthy processing in the GUI thread. See this link on how to create a worker thread http://msdn.microsoft.com/en-us/library/69644x60(v=vs.71).aspx