开发者

Run a background asynchronous process from DLL

I have a DLL that I would like to run as a background process. So in the C# Application I would first like to run this process in the chosen DLL th开发者_运维技巧en let my Application continue with the DLL processes running in the background.

I've seen a few articles and sites but not sure which is the best path to take.

Anyone have any ideas?

Cheers


DLL is not process and can't be run itself. However you can design a windows service and wrap service code around your DLL call to make the functionality available as a continously running background process.

http://msdn.microsoft.com/en-us/library/d56de412(v=vs.80).aspx


Assuming you are choosing the .dll in advance (static binding):

Add the .dll as a reference into your project. Then call MyDll.Core.Start(); where MyDll is the default namespace of your .dll, and Core is a .cs class, and Start() is a function you defined that does ThreadPool.QueueUserWorkItem(new WaitCallback(DoWork), null); and DoWork does your actual background work.

Assuming you want the end-user to choose the .dll from within the application (late binding):

See http://www.c-sharpcorner.com/UploadFile/samhaidar/LateBindingWithReflection09122005053810AM/LateBindingWithReflection.aspx and change GetUserName in the example to Start to match my example above.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜