Skip to content

Instantly share code, notes, and snippets.

@neuecc
Created March 16, 2022 09:52
Show Gist options
  • Select an option

  • Save neuecc/b2e3acbb0b488af6fdb9889ee73f585c to your computer and use it in GitHub Desktop.

Select an option

Save neuecc/b2e3acbb0b488af6fdb9889ee73f585c to your computer and use it in GitHub Desktop.
using DFrame;
using Microsoft.Extensions.DependencyInjection;
// use builder can configure services, logging, configuration, etc.
var builder = DFrameApp.CreateBuilder(7312, 7313);
builder.ConfigureServices(services =>
{
services.AddSingleton<HttpClient>();
});
await builder.RunAsync();
public class HttpGetString : Workload
{
readonly HttpClient httpClient;
readonly string url;
// HttpClient is from DI, URL is passed from Web UI
public HttpGetString(HttpClient httpClient, string url)
{
this.httpClient = httpClient;
this.url = url;
}
public override async Task ExecuteAsync(WorkloadContext context)
{
await httpClient.GetStringAsync(url, context.CancellationToken);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment