<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SuperSocket.Common
{
    public static class Async
    {
        public static void Run(Action task)
        {
            Run(task, TaskCreationOptions.None);
        }

        public static void Run(Action task, TaskCreationOptions taskOption)
        {
            Run(task, taskOption, null);
        }

        public static void Run(Action task, Action<Exception> exceptionHandler)
        {
            Run(task, TaskCreationOptions.None, exceptionHandler);
        }

        public static void Run(Action task, TaskCreationOptions taskOption, Action<Exception> exceptionHandler)
        {
            Task.Factory.StartNew(task, taskOption).ContinueWith(t =>
                {
                    if (exceptionHandler != null)
                        exceptionHandler(t.Exception);
                    else
                        LogUtil.LogError(t.Exception);
                }, TaskContinuationOptions.OnlyOnFaulted);
        }
    }
}<commit_msg>mainline: return AsyncTask when you invoke Async.Run<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SuperSocket.Common
{
    public static class Async
    {
        public static Task Run(Action task)
        {
            return Run(task, TaskCreationOptions.None);
        }

        public static Task Run(Action task, TaskCreationOptions taskOption)
        {
            return Run(task, taskOption, null);
        }

        public static Task Run(Action task, Action<Exception> exceptionHandler)
        {
            return Run(task, TaskCreationOptions.None, exceptionHandler);
        }

        public static Task Run(Action task, TaskCreationOptions taskOption, Action<Exception> exceptionHandler)
        {
            return Task.Factory.StartNew(task, taskOption).ContinueWith(t =>
                {
                    if (exceptionHandler != null)
                        exceptionHandler(t.Exception);
                    else
                        LogUtil.LogError(t.Exception);
                }, TaskContinuationOptions.OnlyOnFaulted);
        }
    }
}
{'fraction_non_alphanumeric': 0.07831060272767268, 'fraction_numerical': 0.0, 'mean_word_length': 2.007936507936508, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7187047', 'n_tokens_mistral': 556, 'n_tokens_neox': 538, 'n_words': 132}