Search Results

Search found 1226 results on 50 pages for 'asynchronous'.

Page 19/50 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • Redirecting before POST upload has been completed

    - by vartec
    I have form with file upload. The files to be uploaded actually are pictures and videos, so they can be quite big. I have logic which based on headers and first 1KB can determine if the rest will be processed or immediately rejected. In the later case I'd like to redirect client to error page without having to wait for upload to finish. The case is, that just sending response before POST is complete doesn't seem to work. The redirect get's ignored and if I close connection, browser complains with "Connection reset by peer" error. So the question is: is it even possible to do that in pure HTTP (without JavaScript on client-side), and if so, how?

    Read the article

  • iphone dev - loading table content asynchronously

    - by Brian
    My app has a navigation controller which push and pop a series of views. One of the tableViews loads .xml file from URL and it takes 4-5 seconds. If I click the back button on the navigation bar, it will only respond after the content of the table finish loading. Is there an easy way to load the content asynchronously so that the app will still respond to my gesture on the navigation bar? p.s. I search this on the Internet and people are talking about multithreading. I don't know a lot about threads so please be more specific. Thanks in advanced =)

    Read the article

  • Adding cancel ability and exception handling to async code.

    - by Rob
    I have this sample code for async operations (copied from the interwebs) public class LongRunningTask { public LongRunningTask() { //do nowt } public int FetchInt() { Thread.Sleep(2000); return 5; } } public delegate TOutput SomeMethod<TOutput>(); public class GoodPerformance { public void BeginFetchInt() { LongRunningTask lr = new LongRunningTask(); SomeMethod<int> method = new SomeMethod<int>(lr.FetchInt); // method is state object used to transfer result //of long running operation method.BeginInvoke(EndFetchInt, method); } public void EndFetchInt(IAsyncResult result) { SomeMethod<int> method = result.AsyncState as SomeMethod<int>; Value = method.EndInvoke(result); } public int Value { get; set; } } Other async approaches I tried required the aysnc page attribute, they also seemed to cancel if other page elements where actioned on (a button clicked), this approach just seemed to work. I’d like to add a cancel ability and exception handling for the longRunningTask class, but don’t erm, really know how.

    Read the article

  • Exciting new Evented I/O technologies

    - by Saif Bechan
    Lately I have been having my eye on evented I/O to tackle some of my web application problems. I have been looking at things as Python's Twisted, Ruby's Eventmachine, and Node.js. Are there any other alternatives to these three, maybe in other languages as PHP ?

    Read the article

  • Multiple instances of the same Async task (Windows Phone)

    - by Bart Teunissen
    After googeling for ages, and reading some stuff about async task in books. I made a my first program with an async task in it. Only to find out, that i can only start one task. I want to run the task more then once. This is where i found out that that doesn't seem to work. to be a little bit clearer, here are some parts of my code: InitFunction(var); This is the Task itself public async Task InitFunction(string var) { _VarHandle = await _AdsClient.GetSymhandleByNameAsync(var); _Data = await _AdsClient.ReadAsync<T>(_VarHandle); _AdsClient.AddNotificationAsync<T>(_VarHandle, AdsTransmissionMode.OnChange, 1000, this); } This works like a charm when i execute the task only once.. But is there a possibility to run it multiple times. Something like this? InitFunction(var1); InitFunction(var2); InitFunction(var3); Because if i do this now (multiple tasks at once), the task it wants to start is still running, and it throws an exeption. if someone could help me with this, that would be awesome! ~ Bart

    Read the article

  • How can I use multi-threading with a "for" or "foreach" loop?

    - by saafh
    I am trying to run the for loop in a separate thread so that the UI should be responsive and the progress bar is visible. The problem is that I don't know how to do that :). In this code, the process starts in a separate thread, but the next part of the code is executed at the same time. The messageBox is displayed and the results are never returned (e.g. the listbox's selected index property is never set). It doesn't work even if I use, "taskEx.delay()". TaskEx.Run(() => { for (int i = 0; i < sResults.Count(); i++) { if (sResults.ElementAt(i).DisplayIndexForSearchListBox.Trim().Contains(ayaStr)) { lstGoto.SelectedIndex = i; lstGoto_SelectionChanged(lstReadingSearchResults, null); IsIndexMatched = true; break; } } }); //TaskEx.delay(1000); if (IsIndexMatched == true) stkPanelGoto.Visibility = Visibility.Collapsed; else //the index didn't match { MessagePrompt.ShowMessage("The test'" + ayaStr + "' does not exist.", "Warning!"); } Could anyone please tell me how can I use multi-threading with a "for" or "foreach" loop?

    Read the article

  • AngularJS directives with async content

    - by SirDavik
    I'm generating a dynamic number of Google Charts tables after receiving the content through an ajax request and I wanted to apply an accordion effect on them. I wanted to know if I could do that with directives (since if I just code render the angular tags they won't get interpreted). I don't need a code example, just a short answer to see if I should learn directives or if I should do it in a different way (I was thinking routeParams). Thanks!

    Read the article

  • Android app crashes on Async Task

    - by Telmo Vaz
    why is my APP crashing when I invoke the AsyncTask? public class Login extends Activity { String mail; EditText mailIn; Button btSubmit; @Override protected void onCreate(Bundle tokenArg) { super.onCreate(tokenArg); setContentView(R.layout.login); mailIn = (EditText)findViewById(R.id.usermail); btSubmit = (Button)findViewById(R.id.submit); btSubmit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View thisView) { new LoginProc().execute(); } }); } public class LoginProc extends AsyncTask<String, Void, Void> { @Override protected void onPreExecute() { mailIn = (EditText)findViewById(R.id.usermail); mail = mailIn.getText().toString(); super.onPreExecute(); } @Override protected Void doInBackground(String... params) { Toast.makeText(getApplicationContext(), mail, Toast.LENGTH_SHORT).show(); return null; } } } I'm trying to make the String name get it's value on the preExecute method, but it happens that the app crashes on that point. Even if I take the preExecute and do that on the doInBrackground, it still crashes. What's wrong?

    Read the article

  • .NET web service call slower when performed asynchronously

    - by joelt
    I have an ASP.NET site, and some pages need to call a web service. I used Visual Studio's "Add Web Reference" to auto-generate classes and methods for the web service. When I call the service synchronously, i.e. objService.MethodName("param1"), a call might take a second or so. When I call it asynchronously, i.e., objService.BeginMethodName("param1", AddressOf MyCallback, Nothing), it typically takes about 6 seconds. When debugging, it appears that the bulk of the time is spent waiting between the completion of the BeginMethodName call and the beginning of MyCallback. Does the thread switching really incur that much overhead? Is there another reason for this?

    Read the article

  • More Poll() ?'s

    - by ultifinitus
    Back again! I've been doing some async socket programming with select() on windows,and it's been working quite well. However it's only scalable up to 1024 clients.Poll() is the way to get around that limitation, and I know it works on both linux and unix. But it doesn't work with a windows system correct? I read about WsaPoll(), does it have the exact same functionality? What libraries would I have to link to in order to use it? Can I increase the socket number safely in windows with FD_SETSIZE? My end program will be on a linux server. However I am testing on a windows system right now. Should I just swap my test machine over to a linux box? (probably going to anyway) Otherwise what would you recommend to use with windows? (sorry for all of the questions, I am doing research on my own, I promise =D)

    Read the article

  • overriding callbacks avoiding attribute pollution

    - by pygabriel
    I've a class that has some callbacks and its own interface, something like: class Service: def __init__(self): connect("service_resolved", self.service_resolved) def service_resolved(self, a,b c): ''' This function is called when it's triggered service resolved signal and has a lot of parameters''' the connect function is for example the gtkwidget.connect, but I want that this connection is something more general, so I've decided to use a "twisted like" approach: class MyService(Service): def my_on_service_resolved(self, little_param): ''' it's a decorated version of srvice_resolved ''' def service_resolved(self,a,b,c): super(MyService,self).service_resolved(a,b,c) little_param = "something that's obtained from a,b,c" self.my_on_service_resolved(little_param) So I can use MyService by overriding my_on_service_resolved. The problem is the "attributes" pollution. In the real implementation, Service has some attributes that can accidentally be overriden in MyService and those who subclass MyService. How can I avoid attribute pollution? What I've thought is a "wrapper" like approach but I don't know if it's a good solution: class WrapperService(): def __init__(self): self._service = service_resolved # how to override self._service.service_resolved callback? def my_on_service_resolved(self,param): ''' '''

    Read the article

  • Linux signals with extra information parameter

    - by Tester
    I was to have some extra information in the callback to sa_sigaction handler, it does not seems possible. So I was wondering if you could suggest me alternatives. Basic requirements: Function A raises an signal/event with a pointer to a struct Handler function tackles the event. The handler function would only be called on an event and a loop to wait for the event, as in select() , is undesirable. TIA

    Read the article

  • Does BeginReceive() get everything sent by BeginSend()?

    - by IVlad
    I'm writing a program that will have both a server side and a client side, and the client side will connect to a server hosted by the same program (but by another instance of it, and usually on another machine). So basically, I have control over both aspects of the protocol. I am using BeginReceive() and BeginSend() on both sides to send and receive data. My question is if these two statements are true: Using a call to BeginReceive() will give me the entire data that was sent by a single call to BeginSend() on the other end when the callback function is called. Using a call to BeginSend() will send the entire data I pass it to the other end, and it will all be received by a single call to BeginReceive() on the other end. The two are basically the same in fact. If the answer is no, which I'm guessing is the case based on what I've read about sockets, what is the best way to handle commands? I'm writing a game that will have commands such as PUT X Y. I was thinking of appending a special character (# for example) to the end of each command, and each time I receive data, I append it to a buffer, then parse it only after I encounter a #.

    Read the article

  • SLRequest return nil before block complete

    - by jaytr0n
    I'm having a little trouble thinking through this and deciding if it's a design flaw on my behalf or if I'm missing a piece that could make this work. Basically I'm using the new SLRequest to make a Twitter API call. After the data is returned, I'd like to put it into an object and return that object: -(AUDSlide *) getFollowerSlide { SLRequest *getRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.twitter.com/1.1/followers/ids.json?user_id=%@", [[self.twitterAccount valueForKey:@"properties"] valueForKey:@"user_id"]]] parameters:nil]; getRequest.account = twitterAccount; AUDSlide *slide = [[AUDSlide alloc] init]; [getRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { if ([urlResponse statusCode] == 200) { NSError *jsonError = nil; NSDictionary *list = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&jsonError]; NSLog(@"Number of Followers: %u", [[list objectForKey:@"ids"] count]); slide.title = @"Followers"; slide.number = [NSString stringWithFormat:@"%u",[[list objectForKey:@"ids"] count]]; } else{ slide.title = @"Error"; slide.number = [NSString stringWithFormat: @"E%u", [urlResponse statusCode]]; } }]; return slide; } Of course the slide is returned before the call is complete and returns a nil object. So I'm not sure if I should try to force this into a synchronous request (that seems like it could be a bad idea) or rethink the design. Does anyone have any advice?

    Read the article

  • Exception in C#

    - by user1803513
    I am facing null pointer exception in below code as it is happening very rarely and I tried to debug to replicate the issue but no luck. Can anybody help me what can cause null point exception here. private static void MyTaskCompletedCallback(IAsyncResult res) { var worker = (AsyncErrorDelegate)((AsyncResult)res).AsyncDelegate; var async = (AsyncOperation)asyncResult.AsyncState; worker.EndInvoke(res); lock (IsAsyncOpOccuring) { IsBusy = false; } var completedArgs = new AsyncCompletedEventArgs(null, false, null); async.PostOperationCompleted(e => OnTaskCompleted((AsyncCompletedEventArgs)e), completedArgs); } Null Pointer exception is reported at var async = (AsyncOperation)asyncResult.AsyncState;

    Read the article

  • PHP display progress messages on the fly

    - by XaviEsteve
    Hi everyone, I am working in a tool in PHP that processes a lot of data and takes a while to finish. I would like to keep the user updated with what is going on and the current task processed. What is in your opinion the best way to do it? I've got some ideas but can't decide for the most effective one: The old way: execute a small part of the script and display a page to the user with a Meta Redirect or a JavaScript timer to send a request to continue the script (like /script.php?step=2). Sending AJAX requests constantly to read a server file that PHP keeps updating through fwrite(). Same as above but PHP updates a field in the database instead of saving a file. Does any of those sound good? Any ideas? Thanks!

    Read the article

  • how to deal with async calls in Ajax 4.0(using jquery?)

    - by dexter
    in my code i have done something like this. $.get('/Home/Module/Submit', { moduleName: ModName, moduleParameters: moduleParameters }, function(result) { $("#" + target).html(result); }); when i put alert in the function(result) {..} it shows html perfectly(both in alert and at the 'target'-on the .aspx page) BUT when i remove the alert.. on the page the 'html' don't appear or appear randomly (this method is called multiple times) i think that the 'result' comes to function asynchronously thats why it is not bind with the respective 'div' however in the last iteration it gets bind every time. can we make process stop until data gets bind? or is there any functionality (like alert) which can make data bind.. without disturbing UI (unlike alert)?

    Read the article

  • Waiting for thread to finish Python

    - by lunchtime
    Alright, here's my problem. I have a thread that creates another thread in a pool, applies async so I can work with the returned data, which is working GREAT. But I need the current thread to WAIT until the result is returned. Here is the simplified code, as the current script is over 300 lines. I'm sure i've included everything for you to make sense of what I'm attempting: from multiprocessing.pool import ThreadPool import threading pool = ThreadPool(processes=1) class MyStreamer(TwythonStreamer): #[...] def on_success(self, data): #### Everytime data comes in, this is called #[...] #<Pseudocode> if score >= limit if list exists: Do stuff elif list does not exist: #</Pseudocode> dic = [] dic.append([k1, v1]) did = dict(dic) async_result = pool.apply_async(self.list_step, args=(did)) return_val = async_result.get() slug = return_val[0] idd = return_val[1] #[...] def list_step(self, *args): ## CREATE LIST ## RETURN 2 VALUES class threadStream (threading.Thread): def __init__(self, auth): threading.Thread.__init__(self) self.auth = auth def run(self): stream = MyStreamer(auth = auth[0], *auth[0]) stream.statuses.filter(track=auth[1]) t = threadStream(auth=AuthMe) t.start() I receive the results as intended, which is great, but how do I make it so this thread t waits for the async_result to come in?? My problem is everytime new data comes in, it seems that the ## CREATE LIST function is called multiple times if similar data comes in quickly enough. So I'm ending up with many lists of the same name when I have code in place to ensure that a list will never be created if the name already exists. So to reiterate: How do I make this thread wait on the function to complete before accepting new data / continuing. I don't think time.sleep() works because on_success is called when data enters the stream. I don't think Thread.Join() will work either since I have to use a ThreadPool.apply_async to receive the data I need. Is there a hack I can make in the MyStreamer class somehow? I'm kind of at a loss here. Am I over complicating things and can this be simplified to do what I want?

    Read the article

  • how to call async method until get success response?

    - by ppp
    I am making a async method call through a delegate. Delegate pointing to a function is a void function. How can I know that the async function has been executed successfully and if not the again call that function untill I get success response. here my code- BillService bs = new BillService(); PayAdminCommisionDelegate payCom = new PayAdminCommisionDelegate(bs.PaySiteAdminByOrderNo); payCom.BeginInvoke(OrderNo,null,null);

    Read the article

  • conditional beginReceive

    - by sbenderli
    I am writing a client program that uses Sockets. I would like the client to receive asyncronously UNLESS it is expecting a response, in which case I would like to receive syncronously. My current problem is that because I have to make a call to socket.BeginReceive which waits until there's data on the buffer, the async call always happens prior to the sync call.. How could I temporarily stop BeginReceive from executing? Is there a way to call EndReceive and then once I am done receiving syncronously, I can continue to receive asnycronously?

    Read the article

  • Updating table from async task android

    - by CantChooseUsernames
    I'm following this tutorial: http://huuah.com/android-progress-bar-and-thread-updating/ to learn how to make progress bars. I'm trying to show the progress bar on top of my activity and have it update the activity's table view in the background. So I created an async task for the dialog that takes a callback: package com.lib.bookworm; import android.app.ProgressDialog; import android.content.Context; import android.os.AsyncTask; public class UIThreadProgress extends AsyncTask<Void, Void, Void> { private UIThreadCallback callback = null; private ProgressDialog dialog = null; private int maxValue = 100, incAmount = 1; private Context context = null; public UIThreadProgress(Context context, UIThreadCallback callback) { this.context = context; this.callback = callback; } @Override protected Void doInBackground(Void... args) { while(this.callback.condition()) { this.callback.run(); this.publishProgress(); } return null; } @Override protected void onProgressUpdate(Void... values) { super.onProgressUpdate(values); dialog.incrementProgressBy(incAmount); }; @Override protected void onPreExecute() { super.onPreExecute(); dialog = new ProgressDialog(context); dialog.setCancelable(true); dialog.setMessage("Loading..."); dialog.setProgress(0); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setMax(maxValue); dialog.show(); } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); if (this.dialog.isShowing()) { this.dialog.dismiss(); } this.callback.onThreadFinish(); } } And in my activity, I do: final String page = htmlPage.substring(start, end).trim(); //Create new instance of the AsyncTask.. new UIThreadProgress(this, new UIThreadCallback() { @Override public void run() { row_id = makeTableRow(row_id, layout, params, matcher); //ADD a row to the table layout. } @Override public void onThreadFinish() { System.out.println("FINISHED!!"); } @Override public boolean condition() { return matcher.find(); } }).execute(); So the above creates an async task to run to update a table layout activity while showing the progress bar that displays how much work has been done.. However, I get an error saying that only the thread that started the activity can update its views. I tried doing: MainActivity.this.runOnUiThread(new Runnable() { @Override public void run() { row_id = makeTableRow(row_id, layout, params, matcher); //ADD a row to the table layout. } } But this gives me synchronization errors.. Any ideas how I can display progress and at the same time update my table in the background? Currently my UI looks like:

    Read the article

  • Check for changes with jquery and a database

    - by Steve
    I am doing a notification system. When a new post is published, users will be notified immediately by an small notification on the screen. I am currently using this: setInterval(function(){ checkForChanges(); }, 2*1000); function checkForChanges(){ $.post("http://"+ document.domain + "/posts/checkForChanges/", function(dat){ if(dat>0){ .... /*create notification*/ } }); } And i was wondering if this is the correct way to do it or not. Because, this is calling a PHP function every 2 seconds and making a query to the database. In case there are no new changes, it won't do anything... Thanks.

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >