Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am new to a desktop application and seeing that there are threads used everywhere.
I don't understand why we are using it here and not in webapplications.
We can directly call the method instead of threads.
'Threads used everywhere' is probably an ominous sign of problems to come and possibly past incompetence, but the main reason people use multiple threads in desktop applications is to allow long-running things to happen without freezing the user-interface of the application.
A conventional Windows GUI app has a 'main thread' which is responsible for processing messages received from the OS. These messages are used for all mouse/keyboard interaction, so the moment you stop processing them, the application stops responding (after a few seconds of this, Windows itself will grey-out the app and put 'stopped responding' in the title bar.)
To avoid this ugliness, people move activities which take a long time (either because they need a lot of CPU, or because the may be waiting for I/O (disk, network, etc)) onto other threads. This means that the main thread is free to keep pumping messages.
You do not start the main thread explicitly - Windows gives it to you when the app starts.
You need to be very careful about interaction between background threads and the main thread - there are a bunch of rules and restrictions, and failing to follow them will give you the kind of problems which may not show up immediately, consistently or on your machine at all. That doesn't mean they're not there...
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am a newbie who just started reading about distributed system.
I am wondering what are some use cases for a distributed queue as opposed to queues on each machine.
For example, how RabbitMQ is used among different web servers. How is it used for example in load balancing?
We typically use distributed queues when the up front cost of processing some task is too expensive or otherwise unnecessary. For example, when you upload a video to YouTube, typically there's some processing of the video that occurs before it's displayed on the site. In the modern web, it can be unacceptable for users to have to wait while that processing occurs. So, the video can be stored and a task put on a queue so that processing can take place later. Then, other machines that are polling the queue can process the video at their leisure. This means the user doesn't have to wait for their video to be processed before they can continue on doing other things on the site. It also critically allows for a buffer for periods of high throughput. If users are uploading videos faster than they can be processed by YouTube's servers, the queue grows independently of the back end's ability to process items.
Another consideration is that the distributed nature of the queue allows for fault tolerance. In the YouTube example, that allows the website to respond to the user, assuring the user that their video will eventually be processed. Typically distributed queues have configurable replication levels, where once an item is put on the queue it's guaranteed to be replicated on n nodes and therefore is unlikely to be lost.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am novice to freeRTOS. I am currently working on a project that uses cerebot Mx7ck(PIC32) running freeRTOS. I need to read buttons using some events(i.e using button input as input event)? But I am not allowed to use polling technique or ISR available in freeRTOS.
Professor suggested to use event handler. I do not know anything about event management in freeRTOS. It looks like there is no event handler and management in freeRTOS without using interrupt service routines.
Please help. I got stuck in this for quite a while.
Configure the button to generate an interrupt.
Write an interrupt handler as described on the documentation page for the FreeRTOS PIC32 port (see the "interrupt service routines" section on the following page: http://www.freertos.org/port_PIC32_MIPS_MK4.html )
Have the interrupt service routine do whatever you want to happen when the button is pushed.
If you want the interrupt to unblock a task then you can use a task notification as demonstrated on this page: http://www.freertos.org/RTOS-task-notifications.html or more precisely http://www.freertos.org/RTOS_Task_Notification_As_Binary_Semaphore.html
If you are not using a version of FreeRTOS that supports task notifications then you can use a binary semaphore instead - that is documented also on the FreeRTOS.org website.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I know that a
Multithreaded processing can simultaneously run multiple procedures. For example, a word processor application can check spelling as a separate task while you continue to work on the document. Because multithreaded applications divide programs into independent tasks, they can substantially improve performance in the following ways:
• Multithreaded techniques can make your program more responsive because the user interface can remain active while other work continues.
• Tasks that are not currently busy can yield processor time to other tasks.
• Tasks that use a lot of processing time can periodically yield to other tasks.
• Tasks can be stopped at any time.
• You can set the priority of individual tasks higher or lower to optimize performance.
But i want to know
when i can use multithreading in vb.net ? any examples or an usual app use it
and what is the different if we use it in desktop apps or web applications
thanks .
I think that multithreading is often used in image processing and can often be done in parallel along with the rendering of an animation also, in GUI programming it often helps to have at least two threads when doing something slow, e.g. processing large number of files.
I thought it was the same in desktop apps and web applications though.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am trying to simulate some clicking on a flash control on a window belonging to another executable using the AutoIT COM Object.
Since it is a long-running script I'd like to keep the system usable by normal (read: physical) means meanwhile. I first taught of a virtual machine, then I remembered that WndProc hooking exists.
Now I'd like to simulate clicks with fake WM_* messages instead of using AutoIt because it hijacks the mouse, in order to be able to run the automation in background without the mouse moving by itself and my current active window (i.e. notepad) losing focus.
My problem is that I have no idea on how to achieve the WndProc hooking in Vb.Net. People says a Dll injection is needed but in my previous Realbasic experience I did it in plain win api.
(To write messages I don't know, but to read worked.)
Ps. I've checked and no similar question seems to address this (at least in vb.net).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I'm trying to implement a socket listener in Windows Phone 7.1, which should process the incoming data and make some actions based on it (constantly, without interrupting). As far as I've found this, the info described there confused a lot, so these are the questions:
Is there some ability for the background agent to be run constantly, without interrupting by the system (or with acceptable amount of running time, more than 10 minutes)?
Is there any API to communicate with running agent, something like Android's AIDL?
PS. I cannot use Push Notifications.
No, background agents cannot run constantly. If you need code to execute constantly then you should keep the app running, maybe enable running under lock screen if appropriate.
No, you cannot connect to an agent.
Agents are not like services.
Your sockets requirement sounds like you will run into the same problem presented by this question: Windows Phone 7 (Mango) App gets disconnected when put in background?
PeriodTask is only executed every 30 minutes or so and thus cannot maintain a socket connection. You might want to look into running under the lock screen, as per Matt's answer, or perhaps ResourceIntensiveTask which can run for as long as you want for 10 minutes but only while the phone is connected to power and the phone has > 90% battery.
There is no API to communicate between the two but applications and their tasks share isolated storage, including databases.