Tutorial by Examples: chrono

Get the current date and time. public class Program { static void Main() { // create empty pipeline PowerShell ps = PowerShell.Create(); // add command ps.AddCommand("Get-Date"); // run command(s) Console.WriteLine(&quot...
<script type="text/javascript" src="URL" async></script>
var bufferBlock = new BufferBlock<int>(new DataflowBlockOptions { BoundedCapacity = 1000 }); var cancellationToken = new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token; var producerTask = Task.Run(async () => { var random = new Random(); while (!cancellati...
- (void)testDoSomethingThatTakesSomeTime{ XCTestExpectation *completionExpectation = [self expectationWithDescription:@"Long method"]; [self.someObject doSomethingThatTakesSomeTimesWithCompletionBlock:^(NSString *result) { XCTAssertEqualObjects(@"result", result, @"Re...
-- File counter.vhd -- The entity is the interface part. It has a name and a set of input / output -- ports. Ports have a name, a direction and a type. The bit type has only two -- values: '0' and '1'. It is one of the standard types. entity counter is port( clock: in bit; -- We ...
This is an example of a simple GET API call wrapped in a promise to take advantage of its asynchronous functionality. var get = function(path) { return new Promise(function(resolve, reject) { let request = new XMLHttpRequest(); request.open('GET', path); request.onload = resolve; ...
void SetupAsyncRead(SerialPort serialPort) { serialPort.DataReceived += (sender, e) => { byte[] buffer = new byte[4096]; switch (e.EventType) { case SerialData.Chars: var port = (SerialPort)sender; int bytesToRead = p...
using System.IO.Ports; namespace TextEchoService { class Program { static void Main(string[] args) { var serialPort = new SerialPort("COM1", 9600, Parity.Even, 8, StopBits.One); serialPort.Open(); string message = &quot...
using System; using System.Collections.Generic; using System.IO.Ports; using System.Text; using System.Threading; namespace AsyncReceiver { class Program { const byte STX = 0x02; const byte ETX = 0x03; const byte ACK = 0x06; const byte NAK = 0x15...
Main process source code index.js: const {app, BrowserWindow, ipcMain} = require('electron') let win = null app.on('ready', () => { win = new BrowserWindow() win.loadURL(`file://${__dirname}/index.html`) win.webContents.openDevTools() win.on('closed', () => { win = null ...
You can make code run asynchronously from the main thread using runTaskAsynchronously. This is useful for doing intensive math or database operations, as they will prevent the main thread from freezing (and the server from lagging). Few Bukkit API methods are thread-safe, so many will cause undefin...
Create index.js as const {app, BrowserWindow, ipcMain} = require('electron') let win = null app.on('ready', () => { win = new BrowserWindow() win.loadURL(`file://${__dirname}/index.html`) win.webContents.openDevTools() win.on('closed', () => { win = null }) }) ipcM...
public static async Task PostAsync(this Uri uri, object value) { var content = new ObjectContext(value.GetType(), value, new JsonMediaTypeFormatter()); using (var client = new HttpClient()) { return await client.PostAsync(uri, content); } } . . . var uri = new ...
public static async Task<TResult> GetAnsync<TResult>(this Uri uri) { using (var client = new HttpClient()) { var message = await client.GetAsync(uri); if (!message.IsSuccessStatusCode) throw new Exception(); return message.ReadAsAsyn...
If you want to execute synchronous code asynchronous (for example CPU extensive calculations), you can use Task.Run(() => {}). public async Task DoStuffAsync() { await DoCpuBoundWorkAsync(); } private async Task DoCpuBoundWorkAsync() { await Task.Run(() => { fo...
NSURLRequest * urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://google.com"]]; NSURLResponse * response = nil; NSError * error = nil; NSData * data = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&a...
// Create the request instance. NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://google.com"]]; // Create url connection and fire request NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
Simulation environments A simulation environment for a VHDL design (the Design Under Test or DUT) is another VHDL design that, at a minimum: Declares signals corresponding to the input and output ports of the DUT. Instantiates the DUT and connects its ports to the declared signals. Instant...
describe('Suite Name', function() { describe('#method()', function() { it('should run without an error', function() { expect([ 1, 2, 3 ].length).to.be.equal(3) }) }) })
var expect = require("chai").expect; describe('Suite Name', function() { describe('#method()', function() { it('should run without an error', function(done) { testSomething(err => { expect(err).to.not.be.equal(null) done() }) }) }) }) ...

Page 2 of 3