handler

How do you efficiently build a list within a handler in AppleScript?

和自甴很熟 提交于 2019-12-10 14:49:21
问题 AppleScript documentation suggests the following code to efficiently build a list: set bigList to {} set bigListRef to a reference to bigList set numItems to 100000 set t to (time of (current date)) --Start timing operations repeat with n from 1 to numItems copy n to the end of bigListRef end set total to (time of (current date)) - t --End timing Note the use of an explicit reference. This works fine at the top level of a script or within an explicit run handler, but if you run the same exact

Android runOnUiThread/AsyncTask cannot resolve CalledFromWrongThreadException

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 14:44:45
问题 I'm working for an Android app and implementing a ProgressBar by using AsyncTask class. The problem is that on some devices, it causes "CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views." in onPostExecute. On those devices, the problem occurs 100%. On other devices, it works fine. public final class MyAsyncTask extends AsyncTask<String, Integer, String> { private ProgressBar progress; private ListActivity activity; public MyAsyncTask

Handler.sendMessageDelayed(msg, delay) not working correctly

百般思念 提交于 2019-12-10 13:36:53
问题 I have defined a splashscreen to be shown during loading. But depending on the internet connection it can takes only 600ms to load or sometimes 5000ms. So i defined that the splashscreen is at least shown 3000ms so that the user is not irritated by flackering screen. I define the start of the splashscreen the following way: private void splashScreen() { setContentView(R.layout.splashscreen); splash = (ImageView) findViewById(R.id.splashscreenLayer); startSplashTime = new Date(); new

UIDocumentInteractionController Opening file in a specific app without options

北慕城南 提交于 2019-12-10 13:33:23
问题 I'm using UIDocumentInteractionController to open a file in another app, DropBox. What i'm trying to do is open the file in another specific app , but i only managed so far to display the supported apps and allowing the user to choose. UIDocumentInteractionController *udi = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath: jpgPath]]; [udi retain]; CGRect r = CGRectMake(0, 0, 300, 300); [udi presentOpenInMenuFromRect:r inView:self.view animated:YES]; This

线程模型

寵の児 提交于 2019-12-10 13:10:26
目前存在的线程模型 传统阻塞I/O服务模型 工作图 黄色框: 对象 蓝色框: 线程 白色框: 方法(API) 模型特点 采用阻塞IO模式获取输入的数据 每个连接都需要独立的线程完成数据的输入, 业务处理, 数据返回。 问题分析 当并发数很大, 就会创建大量的线程, 占用很大系统资源 连接创建后, 如果当前线程暂时没有数据可读, 该线程会阻塞在read操作, 造成线程资源浪费 Reactor模式 针对传统阻塞I/O服务模型的两个缺点, 提出了解决方案: 基于 I/O 复用模型: 多个连接共用一个阻塞对象, 应用程序只需要在一个阻塞对象等待, 无需阻塞等待所有连接。当某个连接有新的数据可以处理时, 操作系统通知应用程序, 线程从阻塞状态返回, 开始进行业务处理 基于线程池复用线程资源: 不必在为每个连接创建线程, 将连接完成后的业务处理任务分配给线程进行处理, 一个线程可以处理多个连接的业务。 说明: 通过一个或多个输入同时传递给服务处理器的模式(基于事件驱动) 服务器端程序处理传入的多个请求, 并将它们同步分派到相应的处理线程。因此m Reactor模式也被称为Dispatcher模式 Reactor 模式使用IO复用监听事件, 收到事件后, 分发给某个线程(进程), 这点就是网络服务高并发处理的关键。 基本原理示意图 核心组成部分 Reactor

TinyMCE: How bind on event after its initialized

元气小坏坏 提交于 2019-12-10 12:53:55
问题 I already searched a lot but by google-fu 'ing don't get me any results :( I have an already initialized tinyMCE editor which initialization process I cannot control, so code like the following don't work at all: tinyMCE.init({ ... setup : function(ed) { ed.onChange.add(function(ed, l) { console.debug('Editor contents was modified. Contents: ' + l.content); }); } }); Code like the following doesn't work either since the jQuery tinymce plugin isn't defined: $('textarea').tinymce({ setup:

Uploadify pass formdata variable to handler.ashx

梦想的初衷 提交于 2019-12-10 12:20:01
问题 I am trying to send parameters from my .aspx page into my handler.ashx with the help of "formdata" in uploadify using .net and c# when I upload a file. The parameters are take from textboxes that have values in the. The code is: <script type = "text/javascript"> $(document).ready(function() { $("#<%=FileUpload1.ClientID %>").uploadify({ 'swf': 'Scripts/uploadify.swf', 'uploader': 'Handler.ashx', 'auto': true, 'multi': true, 'buttonText': 'Select File(s)', 'removeCompleted' : false,

Solr and custom update handler

纵饮孤独 提交于 2019-12-10 10:56:22
问题 I have a question about Solr and the possibility to implement a customized update handler Basically, the scenario is this: FIELD-A : my main field FIELD-B and FIELD-C : 2 copyfield with source in A After FIELD-A has its value stored, i need this valued to be copied in FIELD-B and C, then processed (let's say extract a substring) and stored in FIELD-B and C before indexing time. I'm not using DIH. edit: i'm pushing my data via nutch (forgot to mention that) As far as i've understood,

Re-handle request after changes

…衆ロ難τιáo~ 提交于 2019-12-10 10:42:55
问题 I'm trying to use passport.js in a generic way, changing configuration before calling authenticate , but I can't find a way to redirect request to it after. I handle request like this: Entry point : app.get('/authorize/:clientId/:network', authUtils.authorize); Handler : async function authorize(request, response, next) { try { let clientId = request.params.clientId; let network = request.params.network; config = await databaseUtils.getConfig(clientId, network); if(typeof(config) !==

“Delegate to an instance method cannot have null 'this' ” while forwarding an event

会有一股神秘感。 提交于 2019-12-10 10:37:12
问题 Im trying to forward an event OnClientMessage from my class Client over the class Server to outside my libary. Client.cs public class Client { private TcpClient tcpClient; private StreamWriter writer; private Boolean alive = true; private int id; public delegate void OnClientMessageHandler(Client sender, String message); public delegate void OnClientDisconnectHandler(Client sender); public event OnClientMessageHandler OnClientMessage; public event OnClientDisconnectHandler OnClientDisconnect;