Slow loading of winforms application - c#

I have a winform application that accesses a local database ( SQL CE ) and displays the data in a GUI. Now, when the application is launched from my hard drive, it is fast enough (about 2 seconds). However, my users need to run it from a shared/network drive. And in this case, the loading takes much longer, upto 12 or 13 seconds. Is there any work around for this, such as storing a copy of the database in the the local hardrive and then manipulating it and then storing it the network drive. Any other suggestions are welcome.
EDIT:
The thing is this form has to be used multiple times in a single run. And it takes 12 seconds to load on every load.

I would suggest using a Splash screen or an "In Progress" animated gif inorder to give the feeling that something is happening. I realize it won't make the data load faster, but in your case I think giving the user the feeling that something is happening in the background and that the application is not stuck, should be enough.

Splash screen is a good idea to launch a slow windows form. We put initialize some of "caching job" ready to help your application run faster.
About your idea:
copy the database put it in the the local hardrive and then
manipulating it and then storing it the network drive
It is not partial good idea. It will take a lot of efforts if you working on multi-user environment. You will deal with concurrency, synchronize data between local database and network sharing database.
If you want to go with this idea, you should consider using Sync framework from MS. But so far, you should consider about splash screen.

Related

Two desktops running a windows form application shared on a network folder is slow and lags

My name is Grant and I am just graduating college and I have been working on a little reservation system for a campground and I am running into some issues with speed. I know my code is not perfect, but I do believe I have done a pretty good job at writing a nice, neat, organized program.
Right now how I run the application is by storing it on a shared network folder on one of the desktops, and then I run the application from the shared folder on the other desktop. The ISSUE I am having is that there seems to be a little bit of or its slow sometimes. Its almost like the computer cant keep up. Which is strange, because when you run the application on the desktop where the application is actually being shared from, the application works great. Its fast and responsive. So that makes me believe my code is fine because it runs great on that computer so it cant be my code. Which leads me to believe that its either my network(which I also have a hard time believing, because we have no problems streaming multiple things at the same time). We have never had any problems lately with internet speed. So where I am at now is could it possibly be the desktop itself. They are both pretty cheap desktops running the app. If I upgraded and bought two new desktop computers would the speed increase at all?
Any help or advice on the issue would be great. The application is working likes its suppose to, but the speed of it needs to be picked up. If anyone has any advice at all I would very much appreciate it.
Thanks in advance.

Loading components on splash screen

This might be a primitive question but I really like to get more information. I have seen many professional programs have a splash screen and during that a progress bar and some text indicating that program is loading...
I want to know what CAN or SHOULD be loaded during such time? Do they load classes or something? I am noob and do not know what requires loading before a program actually starts.
In summary, yes. They load classes.
If the program's design is modular enough, the outer shell can be small enough to run almost immediately on most devices (think mobile phones here) and display a progress bar while loading behavior (features provided by external modules, assemblies in C#) in the background.
However, that's not always the best approach to program loading. If your user interface can be up and running in less than five seconds on a typical client machine, it may not even be worth a progress bar.
Well it depends on the program. I use a loading screen when my game is randomly generating terrain which can take anywhere between 1 second to 2 minutes.

WinRT timeout during a webrequest to detect slow internet connections

Is there a sample code available online to get WinRT to determine if its a slow internet connection within the first second of a web-request call so that I can cancel the request and switch to a local file at the start of the program. Metro requirements expect the app to boot up under 5 seconds and I need my web-request (of 300kb) to return well before that. its usually fast on WiFi but 3G speed may vary.
You can see if you are running on a 3G or WiFi connection by using the connectioncost api.
When you are on 3G you could consider using the local file anyway and then attempt to update it on the background. Additionally you might increase your logic further by checking if the user is currently roaming or even if he or she is approaching his or her datalimit, all which might influence your decision on where to load from. All this can be done through the same API.
You are also mixing up things a little as far as the 5 seconds for your app to start go. Your app can actually take 15 seconds give or take to provide something and only 5 seconds to suspend before you are forcibly cut off. If the 15 seconds isn't enough to start with you can also replace the default splash screen .. with your own splash screen and continue loading as long as you like. Keep in mind your user might not like it.
Why not load the local file and then try to update it on the background? I am not sure about your use case.

Resizing images on Windows Phone 7 on thread pool thread?

I'm writing a Windows Phone 7 app that deals with a lot of images - These images can range from a few hundred pixels up to 1080P (Potentially higher in future).
Images are very resource intensive so I've gone down the path of caching + resizing images on the phone before displaying them.
This means on first time setup after a user has entered the IP address of the image store I can ask them to wait a few minutes while it's all retrieved/resized/cached. From then on they can have nice and snappy performance.
At the moment my cache manager tracks Images by a dictionary of Uri's and file locations. I have a Queue that processes up to 5 images at a time (Async web requests, resizing is semi done on thread pool thread).
The problem I have is that the WritableBitmap class in Silverlight is a UI element, meaning I have to transition to the UI thread via the Dispatcher to do the actual resizing which is stupid and slows the whole thing down - It also means my Cache Manager is effectively single threaded.
So it goes Cache Manager (Thread Pool) -> Async Web request (Thread Pool) -> Callback (Thread Pool) -> Resizing (UI Thread) -> Marking cache job as complete (Thread Pool).
I've been looking for a 3rd party library that will A) Compile and run on Windows Phone 7 and B) Be able to resize images of various formats by manipulating a stream or byte array and not be dependent on the UI thread.
Any one had any experience with this?
Cheers,
Tyler
In order to reduce the download size and in order to remove the burden of processing from the phone CPU, then I'd push this work out to a web service.
For example, you could host a service like the open source WebImageResizer code somewhere online http://webimageresizer.codeplex.com/ - e.g. on a free AppHarbor server.
Or you could use a commercial (freemium) service like:
http://webresizer.com/app/
http://www.appspotimage.com/
Either of these would enable you to rapidly process the images on a server with a superfast connection and to juse deliver smaller images to the phone with its limited data connection.
The ImageTools library both supports WP7 and suports image resizing, so you might have more success using this.
Try http://writeablebitmapex.codeplex.com/ created by RĂ©ne Schulte. It has a way better performance as the WriteableBitmap that is shipped with the SDK.
Are files you want to display on your server?
If yes, in my opinion you have chosen the wrong approach to this problem. It's pointless to transfer heavy images, then resize them. I recommend keeping them in either low and high resolution on the server.
If not, I can't help you. I found this article but I think you have already seen it.
Tyler - You mention that on initial launch, the application does retrieve the images from an IP address (on the internet I presume)?
This means on first time setup after a user has entered the IP address of the image store I can ask them to wait a few minutes while it's all retrieved/resized/cached. From then on they can have nice and snappy performance.
If that is correct, what I think some of the answers have suggested in creating a proxy is actually a feasible solution. I would structure it like this:
Your App -> Web Request to Proxy Handler
string imageUrl = HttpUtility.UrlEncode("http://[user's_ip]/path_to_image.png");
http://domain.com/your_proxy.ashx?users_image_url=imageUrl
Your proxy handler on the back end should request the image, resize it, and return the resized image back to your application.
Your App -> Cache the Returned Resized Image
Loop as needed...
UPDATED:
It turns out there is a way to resize images on WP7 outside of the UI thread using the native WriteableBitmap class. There is a method called .SaveJpeg() that allows this, and we're using it currently in our WP7 application CitySourced. Your code should look something like this:
wb.SaveJpeg(stream, width, height, orientation, quality);
The only bummer is that it only works by writing a .JPG file and there's no .PNG support. Let me know if this works for your use case.
I don't think your problem is performance so much but how you are going about displaying the images. I think it would be better to always showing a default thumbnail and then update the thumbnail once it has been resized by your background job. The app should be usable much more quickly.
http://www.dtksoft.com/dtkimage.php
This works with all file formats, and is compatible with windows Mobile

Monitoring Framework needed

I'm building a big application with a lot of modules, i want to monitor them. Every module has its own different parameters that I'm interested in, ranging from performance, to logical statuses of components.
Eventually i need to concentrate all this information, and to be able to display it. Is there a framework i can use to achieve this? im using .net 3.5
You could try Munin. Once you install it - you simply write some plugins - small programs that will grab values from your application. And print them to command line in the form of values and labels. For example:
NoRDNS.value 10
Breakin.value 1
LogPassPAM.value 0
NoID.value 0
LogPass.value 100
InvUsr.value 23
LogKey.value 0
RootAttempt.value 0
Floats are OK too.
Munin will call the plugins periodically (every 10 minutes by default) and plot beautiful PNG graphs over time, track the min/max/average info, and organize everything in static HTML pages.
For you, probably the biggest problem with Munin would be setting it up on Windows. I never tried it on Windows - for me it works on Linux. Fortunately official website does have some options for Windows - in particular the munin-node-win32 program. You would need it.
Unfortunately, munin-node-win32 will only collect the data. To store (as RDD) and render the graphs (as PNG) you would need the Munin server. That can run locally or remotely. For running it locally, Cygwing may be and option but a sure way it to setups a virtual machine (see QUEMU or VirtualBox) running a simple setup of Ubuntu or Debian. In there, setting-up the Munin server is very easy - simply, run:
sudo aptitude install munin
and edit /etc/munin/munin.conf - placing the local IP address of the host where your application and munin-node are running. You don't even need to restart anything - Munin will be already configured in CRON so it will read the config file and do its job every 10 minutes as long as the VM is running. Just in case something goes wrong - the logs will be in the usual /var/log folder.
It looks pretty involved but it's easier than writing your own monitoring and graphing framework. I have a close relative who re-invented the wheel and wrote a monitoring/plotting system from scratch in .NET but I would trust Munin much more than his code.
At the end of the day you would point your web-browser to a private network IP address of the VM and get a nice performance report that looks like this.
Try wolfpack.codeplex.com - .net windows service based monitoring framework - fully extensible & ships with loads of plugins!
Provides passive monitoring (polling for data) and active - you app can pump data/kpis/stats into wolfpack. It also provides a geckoboard data api so you can get rich business dashboards in an instant.
PS: I wrote wolfpack!
You can use appfirst product. They have a way of discovering network flow and display what you described. This might solve your question.

Categories

Resources