バックグラウンド スレッドでメソッドを実行するための汎用関数がいくつかあります。通常のスレッド同期の問題以外に危険はありますか?
public static void ThreadRunReturn<TReturn, TArgument>(Func<TArgument, TReturn> func, TArgument arg, bool background = true)
{
Thread th = new Thread(unused => func(arg));
th.IsBackground = background;
th.Start(th);
}
public static void ThreadRunReturn<TReturn, TArgument1, TArgument2>(Func<TArgument1, TArgument2, TReturn> func, TArgument1 arg1, TArgument2 arg2, bool background = true)
{
Thread th = new Thread(unused => func(arg1, arg2));
th.IsBackground = background;
th.Start(th);
}
public static void ThreadRun<TArgument>(Action<TArgument> action, TArgument arg, bool background = true)
{
Thread th = new Thread(unused => action(arg));
th.IsBackground = background;
th.Start(th);
}
public static void ThreadRun<TArgument1, TArgument2>(Action<TArgument1, TArgument2> action, TArgument1 arg1, TArgument2 arg2, bool background = true)
{
Thread th = new Thread(unused => action(arg1, arg2));
th.IsBackground = background;
th.Start(th);
}