progress

Task.Run and UI Progress Updates

血红的双手。 提交于 2019-11-27 08:52:15
This code snippet is from Stephen Cleary's blog and gives an example of how to report progress when using Task.Run. I would like to know why there are no cross thread issues with updating the UI, by which I mean why is invoke not required? private async void button2_Click(object sender, EventArgs e) { var progressHandler = new Progress<string>(value => { label2.Text = value; }); var progress = progressHandler as IProgress<string>; await Task.Run(() => { for (int i = 0; i != 100; ++i) { if (progress != null) progress.Report("Stage " + i); Thread.Sleep(100); } }); label2.Text = "Completed."; }

Can onprogress functionality be added to jQuery.ajax() by using xhrFields?

半城伤御伤魂 提交于 2019-11-27 07:06:40
As suggested here: https://gist.github.com/HenrikJoreteg/2502497 , I'm trying to add onprogress functionality to my jQuery.ajax() file upload. The upload works fine, and the onprogress event is firing, but not as I expected--instead of firing repeatedly at some time interval, it's firing only once, when the upload has completed. Is there a way to specify the frequency of onprogress refreshes? Or, am I trying to do something that can't be done? Here's my code: $.ajax( { async: true, contentType: file.type, data: file, dataType: 'xml', processData: false, success: function(xml) { // Do stuff

Can't grab progress on http POST file upload (Android)

不想你离开。 提交于 2019-11-27 07:01:01
I am developing an Android app which enables the user to upload a file to services like Twitpic and others. The POST upload is done without any external libraries and works just fine. My only problem is, that I can't grab any progress because all the uploading is done when I receive the response, not while writing the bytes into the outputstream. Here is what I do: URL url = new URL(urlString); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoInput(true); conn.setDoOutput(true); conn.setUseCaches(false); conn.setRequestMethod("POST"); conn.setRequestProperty(

How to get a progress bar for a file upload with Apache HttpClient 4?

余生长醉 提交于 2019-11-27 06:41:57
I've got the following code for a file upload with Apache's HTTP-Client (org.apache.http.client): public static void main(String[] args) throws Exception { String fileName = "test.avi"; File file = new File(fileName); String serverResponse = null; HttpParams params = new BasicHttpParams(); params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, true); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpClient client = new DefaultHttpClient(params); HttpPut put = new HttpPut("http://localhost:8080/" + fileName); FileEntity fileEntity = new FileEntity(file, "binary/octet-stream"

How can I display a Progress at start up application in android

时光怂恿深爱的人放手 提交于 2019-11-27 06:31:09
问题 I want to display a progress when the application start, then close progress when all data load completely. How can I do that? 回答1: Use ProgressDialog to show Progress , Thread to load data and Handler to handle refresh UI . In onCreate, mProgressDlg = ProgressDialog.show(this, "App_Name", "Loading data...", true, false); new Thread(new Runnable(){ public void run() { /*Load Data*/ mProgressDlg.dismiss(); hRefresh.sendEmptyMessage(REFRESH); } }).start(); Handler hRefresh = new Handler(){

叶问6

感情迁移 提交于 2019-11-27 05:25:12
《叶问》是知数堂新设计的互动栏目,不定期给大家提供技术知识小贴士,形式不限,或提问、或讨论均可,并在当天发布答案,让大家轻轻松松利用碎片时间就可以学到最实用的知识点。 2018年8月2日,周四 《全方位认识SYS系统库》公开课精彩互动问答: 1、为什么我用root用户调用call ps_setup_enable_instrument('wait');报错说存储过程不存在? 答:sys schema是从MySQL 5.7之后才默认支持,请确保你的数据库版本正确,且先使用use语句切换默认数据库,否则请带上 sys.库名称限定前缀。 2、myisam锁如何查询? 答:MyISAM 不支持事务,所以不存在事务锁,但可以查询表级锁(例如:MDL锁),通常表级锁是Server层添加的锁,与具体的存储引擎无关,所以与InnoDB存储引擎查询方法一致,建议多多尝试即可得出答案。 3、为什么我查询session系统表,当前正在执行SQL的会话的progress为 NULL 呢? 答:对于progress信息,仅支持stages事件(performance_schema.setup_instruments表的name字段以stages开头的采集项),其他事件类型不支持,且就算是stages类型事件,也不是所有的采集项都支持,可以通过观察performance_schema.events_stages

Get download progress in Node.js with request

徘徊边缘 提交于 2019-11-27 05:22:17
问题 I'm creating an updater that downloads application files using the Node module request . How can I use chunk.length to estimate the remaining file size? Here's part of my code: var file_url = 'http://foo.com/bar.zip'; var out = fs.createWriteStream('baz.zip'); var req = request({ method: 'GET', uri: file_url }); req.pipe(out); req.on('data', function (chunk) { console.log(chunk.length); }); req.on('end', function() { //Do something }); 回答1: This should get you the total you want: req.on(

Custom Progress Bar in Android? [closed]

陌路散爱 提交于 2019-11-27 03:54:27
I havent got a clue to how to do this. My progress bar should be the shape of cloud. Can someone direct me to a book, tutorial or just give the right step by step method? Thank you for your time. As shown here you can use image views to get custom scroll bar like effect. The layout XML for custom progress bar in that example is: <RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="center" android:layout_height="wrap_content" android:paddingLeft="30sp" android:paddingRight="30sp">

Android: Progress Dialog spinner not spinning

和自甴很熟 提交于 2019-11-27 03:54:18
问题 This seems to be an Android-wide problem, which you can see in API demos under Views -> Progress Bar -> Dialogs. Basically, if you show a progress dialog, it works as expected the first time around. If you dismiss it and show it again (without destroying the activity or anything like that), the spinning image stops spinning. In the API Demo you can see this by clicking "Show Indeterminate", pressing back to dismiss the dialog, and clicking the button again. I've tried constructing my own

How to measure download speed and progress using requests?

☆樱花仙子☆ 提交于 2019-11-27 03:23:51
问题 I am using requests to download files, but for large files I need to check the size of the file on disk every time because I can't display the progress in percentage and I would also like to know the download speed. How can I go about doing it ? Here's my code : import requests import sys import time import os def downloadFile(url, directory) : localFilename = url.split('/')[-1] r = requests.get(url, stream=True) start = time.clock() f = open(directory + '/' + localFilename, 'wb') for chunk