def onTick(timer, e): global username, password if not String.IsNullOrEmpty(username) and not String.IsNullOrEmpty( password): update() timer.Stop() timer.Interval = TimeSpan.FromMinutes(5) timer.Start()
def GetCachedItem(itemType, path): cacheKey = 'py:albumitem:' + path # lookup in cache item = HttpRuntime.Cache.Get(cacheKey) if item is not None: return item # create new item = itemType(path) # cache it HttpRuntime.Cache.Insert(cacheKey, item, None, DateTime.MaxValue, TimeSpan.FromMinutes(4)) return item
menuItem.Header = "Gmail" for window in Application.Current.Windows: if window is Application.Current.MainWindow and window.ContextMenu is not None: if not window.ContextMenu.Items.Contains(menuItem): window.ContextMenu.Opened += onOpened window.ContextMenu.Items.Insert( window.ContextMenu.Items.Count - 4, menuItem) if not clr.GetClrType(Separator).IsInstanceOfType( window.ContextMenu.Items[10]): separator = Separator() window.ContextMenu.Items.Insert(10, separator) timer.Start() def onStop(s, e): global timer timer.Stop() dateTime = DateTime.Now - TimeSpan(12, 0, 0) menuItem = None separator = None timer = DispatcherTimer(DispatcherPriority.Background) timer.Tick += onTick timer.Interval = TimeSpan.FromMinutes(1) Script.Instance.Start += onStart Script.Instance.Stop += onStop
import clr from System import DateTime, DateTimeOffset, TimeSpan clr.AddReference("WorkTasks") from WorkTasks import WorkTask cut_start = DateTimeOffset(1997, 3, 3, 15, 31, 34, 361, TimeSpan.FromMinutes(500)) cut_details = "artio" account = WorkTask(cut_start, cut_details) cut_duration = TimeSpan.FromSeconds(25570) account.Duration = cut_duration abutting_task = WorkTask(cut_start + cut_duration, "corollarii") not_abutting_task = WorkTask(cut_start + cut_duration + TimeSpan.FromTicks(1), "poenae") def test_abutting(): "Do two WorkTasks abut?" return account.IsAbutting(abutting_task) def test_not_abutting(): "Do two WorkTasks NOT abut?" return account.IsAbutting(not_abutting_task)
def onTick(timer, e): update() timer.Stop() timer.Interval = TimeSpan.FromMinutes(1.5) timer.Start()