Tutorial by Examples: chrono

describe('Suite Name', function() { describe('#method()', function() { it('should run without an error', function() { return doSomething().then(result => { expect(result).to.be.equal('hello world') }) }) }) })
Adding a Product to a Shopping Cart The following example demonstrates how to Add a product (or anything) to a Database Table asynchronously, using AJAX, and TypeScript. declare var document; declare var xhr: XMLHttpRequest; window.onLoad = () => { Start(); }; function Start() { ...
public async Task<actionresult> Index() { return View("View", await db.UserMasers.ToListAsync()); }
Some applications may want to create so-called "Fire & Forget" tasks which can be periodically triggered and do not need to return any type of value returned upon completion of the assigned task (for example, purging old temp files, rotating logs, autosaving state). In this example, w...
It is often necessary to execute a long-running task and use the result of that task once it has completed. In this example, we will create two classes: One which implements the Callable<T> interface (where T is the type we wish to return), and one which contains a main() method. AsyncValueT...
While good software design often maximizes code reusability, sometimes it can be useful to define asynchronous tasks inline in your code via Lambda expressions to maximize code readability. In this example, we will create a single class which contains a main() method. Inside this method, we will us...
public async int call_async () { return 1; } call_async.begin ((obj, res) => { var ret = call_async.end (res); }); To call an asynchronous functions from a synchronous context, use the begin method and pass a callback to receive the result. The two arguments are: obj is a GLi...
Server Side example Create Listener for server Start of with creating an server that will handle clients that connect, and requests that will be send. So create an Listener Class that will handle this. class Listener { public Socket ListenerSocket; //This is the socket that will listen ...
If you have multiple asynchronous tasks that needs to occur one after the other, you will need to chain together their promise objects. Here is a simple example: function First() { console.log("Calling Function First"); return $.get("/ajax/GetFunction/First"); } fu...
The GLib.Task provide low-level API for performing asynchronous operations. var task = new GLib.Task (null, null, (obj, result) => { try { var ret = result.propagate_boolean (); } catch (Error err) { // handler err... } }); Later in a thread or a callback: t...
In order to chain asynchronous operations and avoid a callback hell, Vala supports the yield statement. Used with an asynchronous invocation, it will pause the current coroutine until the call is completed and extract the result. Used alone, yield pause the current coroutine until it's being woken...
const { expect } = require('chai') describe('Suite Name', function() { describe('#method()', function() { it('should run without an error', async function() { const result = await answerToTheUltimateQuestion() expect(result).to.be.equal(42) }) }) })
#include <vector> #include <string> #include <boost/process.hpp> #include <boost/asio.hpp> #include <boost/process/windows.hpp> int Run( const std::string& exeName, ///< could also be UTF-16 for Windows const std::string& args, ...
shared.service.ts: import { Injectable } from '@angular/core'; import { Headers, Http } from '@angular/http'; import 'rxjs/add/operator/toPromise'; import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Rx'; import {Subject} from 'rxjs/Subject'; @Injectable(...
Sometimes you'll need to execute synchronous code from within an asynchronous task. To do this, simply schedule a synchronous task from within the asynchronous block. Bukkit.getScheduler().runTaskTimerAsynchronously(VoidFlame.getPlugin(), () -> { Bukkit.getScheduler().runTask(VoidFlame.ge...

Page 3 of 3