Execute a function when a Flex 3 App finishes execution - apache-flex

I am developing an lib which tracks user events, like button click, state change, module load and application finish.
My problem is how I can track the application finish event. I googled for it, but I found no good answer.
It is possible to use this kind of event?

You need to use ExternalInterface, here is a good example:
Browser Window Close Event and Flex Applications

Related

Is there a way to pause Application Insights alerts (maintenance mode)

I have a few Application Insights monitors in place with alerting. Is there a way to pause these alerts, to define a maintenance window when the site will not be available?
You can enable/disable alerts manually through the Azure Portal.
Just go to your AI application and select the "Alerts" tile. From the alert list select the alert you want to configure, and in the "edit rule" blade, you should see big Enable/Disable buttons.
As far as I know you cannot define a maintenance window that does this automatically.

Stop System.Timers.Timer When Program Stops

I've been thoroughly researching this and haven't been able to find what I need. I am currently working in an asp.net website, code behind being vb.net, and using a timer from system.timers.timer. I have created a page with two buttons, one to start my timer and one to stop my timer. They work mostly as I expect them to.
Here is my question: How do I make the timer stop when my program/site stops running? Not when I exit the browser, but when the actual program running my site stops? For example, when this goes live the program will be running on our server. I want the timer to always run in the background once I've clicked start, unless the site goes down or I click stop. In my development environment, when I click run and click my timer's start button, I want the timer to run until I either click stop or I stop debugging. The problem is that when I stop debugging the timer keeps running. How do I stop the timer when I stop debugging or, when live, the website stops(crashes)?
to stop your timer you have to detect that your application is still running or not and for that you have to write code in your global.asax file.
on Application_end event or may be in Application_EndRequest
for view how to use Global.asax file please review this link
http://www.codeproject.com/Articles/228879/Global-asax-in-ASP-NET
Please check this and try this code.
Thank you.
It looks like a task for a server side code: use Global.asax in this case

Is there a way to open new tab on QTabBar in a new process?

I have a QtGui.QTabBar object that I use in my application. User interaction can open (or close) additional tabs to run various python modules. I'd like to make each of these run in their own process to ensure that longer running/CPU intensive modules don't block simple ones.
There does not need to be interaction between tabs. The only thing that would be needed is a way for the parent (existing) application to know when a tab closes and ensure the child process terminated correctly. I'm planning on using Pythons multiprocessing module to handle this.
Is there a way to make a new tab in a QTabBar open a separate process? If so, how? I've Google'd for 'qtabbar separate processes' and similar, but I haven't found anything that tells me one way or another if this is possible.
I'm using Python 2.7.3, PyQt and Qt 4.9
You can't have a tab running in a new process. Any tab is just a widget, and all GUI is running in the main application thread.
But you can separate GUI from the business logic of your application.
For a single tab you can have a widget itself and a controller that can run in another thread and process your heavy calculations. Then you can connect your tab and its controller with signals/slots mechanism.

ASP.NET page load time question

I need to measure the total time a page takes to fully load, from clicking a menu button to fully rendered. I did that, by using BeginRequest and EndRequest events. Because some numbers were too big, I started measuring the time for every method and event the page executed when loading. Using a stopwatch I timed Preinit, Init, Load etc, all the events in the page life cylcle plus all other methods I created. My surprise was that adding these numbers I didn't even get close to the numbers I got using begin/end request. The last one was even double, triple, eg 7 seconds comparing with the 2 seconds I got from each event/methods.
So I'm wondering, where does this extra time come from? Between my timings, which are showed in the debug window, I could see all sort of "loading jhfggdfaasdf.dll", probably some temporay file. Could this dll loading take this time?
I noticed that from time to time, my timings match, so maybe there is some cache mechanism, but I need some confirmation from someone more experienced.
EDIT: From reading your question again, you might be using the asp.net web site solution type. This is not pre compiled when you are debugging and the first time you request a page it compiles it into a class in your asp.net directory. The dll for the class is then loaded into the app domain with a funny name like the one you mentioned. This happens the first time you request one of these pages and when you want to deploy you can pre compile your site to increase performance.
If you are seeing "loading xyz.dll" it means the app domain is loading in stuff to be used by the application. This happens when you need to run code from required dlls (in your case probably third party libs) that have not yet been loaded into the app domain. This is good because it means a page that uses a library but has never been called, never loads that assembly into memory. You could move this hit from first page request to application load by pre loading all the assemblies in your bin into the app domain on application start. It is a trade off between use of memory against speed of requests. This question is a good place to start with that:
How to pre-load all deployed assemblies for an AppDomain
You can get a good overview of your page lifecycle times by using the trace functionality in asp.net. This can be set in the web.config file as described in this article:
http://msdn.microsoft.com/en-us/library/94c55d08.aspx
Viewing the trace.axd page will tell you times off the various server events and make it really easy to see where you are slow.
If the page still takes a long time to render, there are client side considerations such as
is your page very large
are you interpreting javascript before all the html and css was written
is your network slow
are you sending many css and js files? most browsers limit the number of concurrent resource downloads. maybe consider rolling a few css files into one, on your production environment at least
are you employing client cache. you can tell the browser to cache something for a period of time. there are ways to invalidate this cache if your content requires to be updated.
This can be debugged using client side tools such as firebug or the developer tools in chrome.
The stopwatch is actually a fairly cumbersome object by itself. You may actually be adding to the load time by using it to record the time. A slightly more efficient method would be to use a simple datetime comparison.
protected void Pre_Init(object sender, EventArgs e)
DateTime started = DateTime.Now;
// .... some code
lblDisplayComment.Text = DateTime.Now.Subtract(started).TotalMilliseconds.ToString();
}
This would give you the time in ms it took to execute that method only.

How to get Flex app to load quicker?

We've got an app written in Flex that displays data from our app. The .swf file is only 427kb, but it takes a full five seconds to load in Firefox. This is a headache for our users because they need to access the page that contains the app frequently. (The app displays documents, and it's really slow to march through a list of them).
I've confirmed that it's not a slow web server problem. The .swf appears to be cached in the browser. Firebug reports that every time the web page accesses the .swf, the app server returns a "304 Not Modified" response, meaning that the load time from the server is almost zero.
Is there anything we can do to debug this issue? Or is the Flash player just slow?
If you're having issues with the time to download the SWF or to initialize the application, you could try breaking it up into modules and using the SWFLoader to only load the pieces as you need them. Flex applications are 2-frame movies, so the more you have in your application the more there is to initialize before it can start "playing."
If it's slow rendering everything, take a look at the creationPolicy and see if you're needlessly creating a hierarchy of items that aren't being displayed. Repeaters are also notorious for rendering slowly.
If your performance problems are more in-application, then you could consider profiling your application to see where the hotspots are.
Have you tried running the app using the Flex Profiler? That may help you isolate any performance issues.
Consider checking out the Flex RSLs. These runtime shared libraries allow the Flash Player to cache the Flex framework and after the first load allow for a much faster startup time.
Look at the
creationPolicy documentation.. it may help..
The default should be "auto"... Creates all controls only in the initial view of the navigator container. This setting causes a faster startup time for the application, but results in slower response time for user navigation.
This setting is the default for multiple-view containers.
See if someone has changed your setting.

Resources