This sample allows you to highlight C# source code. Highlighting is based on http://hilite.me web service, which is called from a background job in a truly asynchronous way – neither controller, nor any other entity is waiting for a completion. Results are delivered via WebSockets using SignalR.

All the snippets are removed every day at 12:00 AM UTC.

namespace Hello
{
    class App
    {
        async Task Main()
        {
            System.Console.WriteLine("Hello!");

            await Task.CompletedTask;
         }
   }
}
      protected override void Execute()
        {
            int timeout =  (Timeout != null) ? Timeout.Value :  10;
            string statusProperty = (StatusProperty != null) ? StatusProperty.Value : string.Empty;
            string serviceName = (ServiceName != null) ? ServiceName.Value : string.Empty;
            string server = (Server.Value != null) ? Server.Value : string.Empty;

            if (string.IsNullOrEmpty(serviceName))
            {
                throw new CommandException("No service identified!");
            }

            if (string.IsNullOrEmpty(server))
            {
                throw new CommandException("No server identified!");
            }

            if (serviceName.Equals("PsExec", StringComparison.CurrentCultureIgnoreCase))
            {
                serviceName = "PSEXESVC";
            }

            ServiceController svc = ServiceController.GetServices(server).FirstOrDefault(sc => sc.DisplayName.Equals(serviceName, StringComparison.CurrentCultureIgnoreCase) || sc.ServiceName.Equals(serviceName, StringComparison.CurrentCultureIgnoreCase));
            if (svc == null)
            {
                throw new CommandException(string.Format("Could not find service [{0}] from service controller on machine [{1}]", serviceName, server));
            }

            Exception exp = null;
            TimeSpan timeoutSpan = new TimeSpan(0, 0, timeout);
            Stopwatch sw = new Stopwatch();
            sw.Start();
            while (svc.Status != ServiceControllerStatus.Stopped && sw.Elapsed <= timeoutSpan)
            {
                try
                {
                    svc.Stop();
                    svc.WaitForStatus(ServiceControllerStatus.Stopped, timeoutSpan);
                    svc.Refresh();
                }
                catch (Exception ex)
                {
                    exp = ex;
                }
            }
            sw.Stop();
            if (svc.Status != ServiceControllerStatus.Stopped)
            {
                if (exp == null)
                {
                    throw new CommandException(string.Format("The service [{0}] could not be stopped in the time period [{1}].", serviceName, timeout));
                }
                else
                {
                    throw new CommandException(string.Format("An error occured trying to stop service [{0}].&nbsp;&nbsp;{1}", serviceName, exp.Message));
                }
            }
            else
            {
                string status = svc.Status.ToString();
                Log(true, "Status after attempting to stop service [{0}] on machine [{1}] is {2}", serviceName, Server.Value, status);
                if (!string.IsNullOrEmpty(statusProperty))
                {
                    SetProperty(statusProperty, status);
                }
            }
        }
using System;
using System.Data;
using System.Threading;
using System.Threading.Tasks;

System.Thread.Sleep(20000);
Console.WriteLine("I want to see!");
using System;
using System.Data;
using System.Threading;
using System.Threading.Tasks;

System.Thread.Sleep(20000);
Console.WriteLine("My, world!");
System.Thread.Sleep(20000);
Console.WriteLine("Hello, world!");
DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123);

String.Format("{0:y yy yyy yyyy}", dt);  // "8 08 008 2008"   year
String.Format("{0:M MM MMM MMMM}", dt);  // "3 03 Mar March"  month
String.Format("{0:d dd ddd dddd}", dt);  // "9 09 Sun Sunday" day
String.Format("{0:h hh H HH}",     dt);  // "4 04 16 16"      hour 12/24
String.Format("{0:m mm}",          dt);  // "5 05"            minute
String.Format("{0:s ss}",          dt);  // "7 07"            second
String.Format("{0:f ff fff ffff}", dt);  // "1 12 123 1230"   sec.fraction
String.Format("{0:F FF FFF FFFF}", dt);  // "1 12 123 123"    without zeroes
String.Format("{0:t tt}",          dt);  // "P PM"            A.M. or P.M.
String.Format("{0:z zz zzz}",      dt);  // "-6 -06 -06:00"   time zone
wrt rtrtrttr
Console.WriteLine("Hello World!");
System.Thread.Sleep(20000);
Console.WriteLine("Hello, world!");
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Hangfire;
using Hangfire.MemoryStorage;
using Serilog;
vbvb
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Hangfire;
using Hangfire.MemoryStorage;
using Serilog;

namespace BusinessAppPOC
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            Log.Logger = new LoggerConfiguration()
                .ReadFrom.Configuration(Configuration)
                .CreateLogger();

            services.AddLogging(configure => configure.AddSerilog());

            services.AddHangfire(configuration => configuration
                .SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
                .UseSimpleAssemblyNameTypeSerializer()
                .UseRecommendedSerializerSettings()
                .UseMemoryStorage()
                );
            services.AddHangfireServer();

            services.AddRazorPages();
            services.AddSession();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IBackgroundJobClient backgroundJobs, ILogger<Startup> logger)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseSerilogRequestLogging();

            //app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseHangfireDashboard();
            backgroundJobs.Enqueue(() => Log.Information("Hello World from Hangfire!"));

            RecurringJob.AddOrUpdate(() => Log.Information("Here's a recurring job."), Cron.Minutely);

            app.UseRouting();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
            });
        }
    }
}
            app.UseSerilogRequestLogging();

            //app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseHangfireDashboard();
            backgroundJobs.Enqueue(() => Log.Information("Hello World from Hangfire!"));

            RecurringJob.AddOrUpdate(() => Log.Information("Here's a recurring job."), Cron.Minutely);

            app.UseRouting();
using System;
using System.Data;
using System.Threading;
using System.Threading.Tasks;

System.Thread.Sleep(20000);
Console.WriteLine("My, world!");
using System;
using System.Data;
using System.Threading;
using System.Threading.Tasks;
for(int i =0;i < 500000000;i++){
Console.WriteLine(i);
}
System.Thread.Sleep(20000);
Console.WriteLine("Hello, world!");
System.Thread.Sleep(2000);
Console.WriteLine("Hello, world!");
Console.WriteLine("beebop!");
Console.WriteLine("Hello, world!");