如何在后台任务和主应用程序之间共享一个类? [英] How to share a class between a background task and main App?
问题描述
我的主应用程序有一个Class1.cs,我想在我的计时器后台任务中重用它。后台 任务 本身每15分钟触发一次,但是当我执行 "Add-As-Link"时,编译器会失败。在Class1.cs上进入后台任务项目。
显然,后台任务类已在主应用程序中引用,并且应用程序中似乎存在编译器冲突..
My main App has a Class1.cs which I want to re-use in my timer background task. The background task itself trigs as as expected every 15 min, but the compiler fails when I do "Add-As-Link" on Class1.cs into the background task project. Obviously the background task class is already referenced in the main App and there seems to be a compiler conflict in App..
我该如何解决这个问题?
How can I get around this ?
推荐答案
看看我是如何在这个项目中做到的:
have a look how i did it in this project:
http://code.msdn.microsoft.com/windowsapps/Tile-Update-every-minute- 68dbbbff
我把后台任务的工作推到了自己的班级。我也在应用程序中使用的那个类
i putted the work of the background task in a own class. that class i also using in the app
这篇关于如何在后台任务和主应用程序之间共享一个类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!