I have been developing a j2me application for TC65 that needs to receive the GPS data and save that data in file and this file will be sent to a server using a timer. At some instances the application closes and the console shows "notifyDestroyed() not called in time" . I called this method when I need to close the application. But the console didn't show any logs that I have put before this call. I think the system called that method before closing the application. If so what was the reason to exit the application??
MIDP application manager(AMS) can signal midlet to move to destroyed state at anytime. It usually happens when the system is running low on resources (for example memory). Check if the destroyApp() method of your midlet is called, if it is then it is the AMS that is closing the midlet.
Related
I've written a windowless NPAPI plugin, and I am going to perform some long lasting operation (e.g.send a http post request with image data) in a plugin function called by web browser JavaScript.
To prevent web browser from hanging, I create one worker thread for every lengthy operation.
My question is that if the browser is closed while there are still worker threads running,
how can I prevent my plugin instance from being destroyed (in NPP_Destroy?) before worker threads completed?
For ActiveX control, I simply add/release plugin instance's reference count every time the worker thread is launched/completed. But for NPAPI plugin, the reference count is just for NPObject(created via NPN_CreateObject) instead of plugin instance itself. Now I get baffled.
Any help would be really appreciated.
You can't. I suppose you could launch another process and perform the operations in that; that way you could send it a signal when the plugin shuts down and say "you need to close, when you're ready" but not have it close 'til it finishes.
The plugin itself -- even in IE -- you can't control when it shuts down because if the browser shuts down it'll close all plugins at that point anyway.
Welcome to plugin land -- you don't get to control the lifecycle.
I made an jsf application.This application has a menu containing start,stop buttons.When start is pressed , application starts to get data from web sites, and updates its database.The application also has progress bar for update process.However,this process takes a long time to finish.I want that when i close my browser , it should go on updating database.Besides, when i open it again, i should get previous state.However, this isn't happening.When i close browser the application closes too.How do i do that?
Thanks.
In my case, I would not extend the session life. Instead, create a task and add the object that performs the task into a Queue in an #ApplicationScoped bean and save in database (or any other place) the user that started the job and the status of the job.
When the user logs off (manually logging off or closing the web browser), the task will still be executed because is managed by the whole application (not by a request nor user session). When the user logs in again, he/she could ask to this application queue about the status of the task.
You will need (at least):
An #ApplicationScoped managed bean that will contain and handle the tasks.
A way to handle and execute one or more tasks at the same time. This could be achieved with a ExecutorService or similar technologies. Note: don't dare to manually start new threads by your own, this will only lead to kill your web application server.
An structure to map the user with the tasks he/she has started. It could be mapped with a Map<String, List<Task>> in order that a single user could have more than 1 task at the moment. It would be better to save this in a database (or similar) in order to have a log for these tasks that don't reside in memory. You can even design this in order that if you undeploy the web application or the server suddenly shut downs, you could restart the tasks at hand from a savestate point.
when I test my app in cocoa I can read some "[Switching to process XXXX thread 0xXXXX]" that I'm not understanding...
When app creates a thread?
For example, when I mouseover some main menu items, I get [Switching to process XXXX thread 0xXXXX]
Why?
Apple can reject my application of app store for this reason?
Thx!
It's neither an error, nor a problem. It's a normal part of an application running in the debugger.
Do the menu items have a custom image, or use any animation effects?
The messages in the debugger are only showing that the application has switched to another thread to handle the processing and unless I am missing something, I don't think there is any need to worry about them.
Our app, which has been in the app store for a few months uses images and animation on certain sections and gets process switching notifications in the debugger and has never been rejected for that fact.
The client application will register requests to monitor events on the server. The Client's call back is added to a dictionary (and refreshed by the client on a regular interval)
The server will monitor an MSMQ private queue for events, and when an event that a subscriber has registered for occurs the server will call the client(s).
This hinges on starting a background thread that can wait on the MSMQ and then call the registered client apps. What is the best way to start up this background thread? My first through was to simply launch it in the Application_Start event of the global.asax file. This has a number of pitfalls, as discussed in Chris Anderson's answer to this SO question Furthermore, this the pitfall of the thread lingering around on the developer machine after they stop debugging the app.
Perhaps there's a completely different approach that is warranted, such suggestions are also welcome.
Why not start your background thread when the first client registers, and signal it to stop when the last client unregisters or times out?
How do you handle update refresh rate from your worker function to your UI ?
Sending everything to the UI or maybe using a timer (from which side ? worker or UI ?)
In Windows apps, you generally want to use a Timer object in your GUI thread to poll for worker status -- it's easier, unless you have a really good reason to do something else...
You can't just make a function call to a UI routine from a worker thread in Windows. Undefined behavior will result, so watch out!
If your platform and development environment supports it some sort of asynchronis messaging system works well. Under Win32 I just use normal windows messages which I "post" (so they don't block the thread) and the standard main message thread of the UI picks up the messages and processes them. I usually define custom messages as well.
Using Timers is suboptimal, there should be no need to "poll" this sort of information.