1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MemoryCacheクラスはバグがありカルチャが英語以外だと内部で無限ループに入りハングアップするのでその回避方法をメモ

Posted at

MemoryCacheクラスはバグがあり、カルチャが英語以外だと内部で無限ループに入りハングアップする。
参考URL)https://github.com/SignalR/SignalR/issues/3414

MapSignalRメソッド内部のPerformanceCounterクラスの中あたりでもMemoryCacheが使われているのでSignalRもうまく動かなくなるときがあるかも。
最新の.NETでは直っているのかな?回避方法をメモ。

public static MemoryCache CreateMemoryCache()
{
        CultureInfo ci = Thread.CurrentThread.CurrentCulture;
        var lcid = CultureInfo.CurrentCulture.Parent.LCID;
        if (lcid != 9)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(1033);
        }
        var myCache = new MemoryCache(MyCachePrefix, MyCacheConfig);
        if (lcid != 9)
        {
            Thread.CurrentThread.CurrentCulture = ci;
        }
        return myCache;
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?