How can I lag a computer in c#? CREATE lag! -
this odd question, understand. assumed simple, because lord knows have created share of infinite loops.
i'm trying cause slight pc lag in c# - need create 'choppy mouse' situation system wide (not sandboxed exe).
the little app can't crash computer! lag should able run 2-10 seconds ish - stop.
what have tried far: -spawning numerous threads save data (filled memory , cause pf usage, no real lag).
-spawning tons of threads (lag @ first, none when treads re-spawned again - if second time os ready).
-spawning threads take several screenshots (the screenshots don't seem lag).
none of these have worked - ideas?
optional story (optional): reason application, without divulging company information, cover laggy background process in production environment. have tried speed app up, or improve computers no results. there abuse case present when production workers associate lag background application running. goal disassociate lag ... creating similar 1 @ random times sparingly.
clarification: original background app not home grown (fyi) real solution purchase 1000s of new boxes. company going cheaper 'hide background app' ... 'solution'. know...
you can create background app randomly calls windows blockinput api @ desired interval. allows app have small footprint possible preventing taking cpu cycles , memory.
more information here: http://msdn.microsoft.com/en-us/library/ms646290.aspx
that said, agree other posts / comments addressing symptoms , not problem.
edit: code example
using system.runtime.interopservices; using system.threading; namespace lagtimer { class program { [return: marshalas(unmanagedtype.bool)] [dllimport("user32.dll", charset = charset.auto, exactspelling = true)] public static extern bool blockinput([in, marshalas(unmanagedtype.bool)] bool fblockit); static void main(string[] args) { thread t = new thread(lagtick); t.start(); while (true) { } // prevent app exiting } static void lagtick() { while (true) { blockinput(true); system.threading.thread.sleep(250); blockinput(false); // todo: randomize time in between ticks thread.sleep(100); // todo: add logic when "sputter" mouse } } } }
Comments
Post a Comment