It has any possible to create a thread to send request to server in background - react-native

I want to write a function that can send request to server continuously in background. But I don't know to use thread in React Native. Can you give me some and suggestions.and it is best don't use native codes.

Javascript is single-threaded, so you can't manage/create threads.
You can read about the threading model here.
The interesting part for you is that network requests in javascript don't pause your thread. They always run in the background and will resume work on the JS thread once they are completed.

#RichardSleet you can do that with help of webworkers
A web worker is a JavaScript that runs in the background, independently of other scripts, without affecting the performance of the page
so when you create new worker
each worker will have whole new CONTEXT
Example : You can run 10 for loops parallely with webworkers

Related

How to fetch data asynchronously in Cocoa Application using objective C

I am fetching some system information e.g. processor name processor cores and many more and then showing them on NSTextFeild.
The issue is for the time the information is getting fetched, the application hangs.
So, I want to run the task asynchronously.
Note: I have just started with cocoa so please do describe your solution. pretty please..
thanks in advance.
Your UI hangs because you are doing work on the main thread. Hence this is a thread problem. You can then run that fetch for information on another thread, a background thread that doesn't interact with the UI, display something to the user that the data is currently getting retrieved and then, when the data is ready, display it in your NSTextField.
Read more
Understanding dispatch_async
https://developer.apple.com/library/ios/documentation/Performance/Reference/GCD_libdispatch_Ref/

Is there a way to update GUI or use GUI while CPU is working?

The GUI of my program freezes while the program is doing its work. I created a mass import which can send X-thousand datarows via a called webservice into a database. The code is already very big and I cannot rewrite it for multithreading purpose.
I don't know how to do it. Any suggestions? If needed I will show some code, but at the moment I don't know what to show.
Firstly, you should rewrite it to use avoid synchronously doing this on the UI thread. If you do a lot of work on the UI thread, it simply will freeze the UI thread. There are a few options here:
If your web service proxy supports asynchronous calls, and if you're using VB 11, you can use Async / Await to call the web service asynchronously from the UI thread in an asynchronous method, and control will return back to the UI thread at the same point in the asynchronous method when the call has completed. It takes a little while to get your head round asynchrony, but this is probably the best option if it's possible.
You can use the Task Parallel Library to make calls on a different thread, but then you'll need to think carefully about how that thread is going to interact with your UI thread.
You can use BackgroundWorker to run some code on another thread, but report progress and completion back on the UI thread
You could potentially call Application.DoEvents between each web service call, to let the UI handle events. This is dangerous - it can lead to re-entrant code, so locks won't behave as you expect them to, and similar hard-to-diagnose errors. This should be your last option, if all else fails.

Run script after windows store app has been installed

Is there any way to run some activity after a Windows Store app has been installed?
I'd like to get some data from a webservice (data is rarely changes), but I would not like to make the query on the first start, because it might take some time, and I don't want to ruin the user experience.
Thanks!
You can have it run on a separate background thread while concurrently running the main thread. You can allocate limited resources to this separate background thread, then have it subside on it's own.
You can do an async operation as well from your app, see link from MSDN:
http://msdn.microsoft.com/en-us/library/windows/apps/br230301.aspx#AsyncOps
My codeSHOW app loads data asynchronously when it first starts, and stores the async promise as an app level variable so anything else in the app can await it. It's not exactly what you're looking for, but if it helps, it's available at http://codeshow.codeplex.com.

vb.net web application threading

I have some functions in a web application that do a lot of calculations and as a result have high CPU usage which affects the rest of the application when other users are accessing it.
I have tried backgroundworker to no avail , the only thing that seems to work in using another thread and setting the priority to low, can the UI be updated from a worker thread? specifically I am trying to bind a grid to a dataset processed in the worker thread
If you call Application.DoEvents() periodically to process the windows message queue, this will allow the UI to be updated and respond to user input.
You need to understand that many people consider DoEvents to be evil. As the UI will respond to events such as click, you should beware of any issues this can cause such as allowing many of your heavy CPU BackgroundWorker threads to be spawned. However, used correctly DoEvents provides a valid strategy for keeping your application responsive during processing.

IDuplexSessionChannel BeginSend not sending during high UI thread tasks

We have a Silverlight 4 application utilizing an IDuplexSessionChannel to send data to/from the application to a WCF service.
I've noticed that during very high UI thread usage (such as application startup when the UI is building itself) calls to our WCF service via IDuplexSessionChannel.BeginSend are not sent until the UI has completed rendering.
The calls to BeginSend are being done within a BackgroundWorker.
Does the actual execution of BeginSend occur on the main thread? I couldn't find anything "official" that documents this.
It would seem so since even if I have the main thread Sleep or WaitOne the messages still do not go through (note this was just a test).
What would be the best way to get those calls to go out immediately?
Thanks