public IActionResult Index() { _cache.TryGetValue(CacheKeys.Entry, out string data); var isDataFromCache = true; if (string.IsNullOrWhiteSpace(data)) { Thread.Sleep(2000); data = System.IO.File.ReadAllText(_filePath); isDataFromCache = false; _memoryCacheTest.SetItemInCacheTest(_filePath); } ViewBag.Data = data; ViewBag.IsDataFromCache = isDataFromCache; ViewBag.ProcessID = Process.GetCurrentProcess().Id; ViewBag.ProcessList = Process.GetProcessesByName("w3wp").ToList(); ViewBag.ProcessListCount = ViewBag.ProcessList.Count; ViewBag.ProcessName = Process.GetCurrentProcess().ProcessName; return(View()); }
// Define the event handlers. private void OnChanged(object source, FileSystemEventArgs e) { // Specify what is done when a file is changed, created, or deleted. Debug.WriteLine($"File with Path: {e.FullPath} and name {e.Name} has change type of {e.ChangeType}"); _memoryCacheTest.SetItemInCacheTest(e.FullPath); }