简体   繁体   English

在后台任务中使用主项目中的类

[英]Use classes from main project in background task

How can I use classes which are part of the main project in a background task project. 如何在后台任务项目中使用作为主项目一部分的类。 I wrote a helper class that manages operations on the local sqlite database, do I have to duplicate this class and copy it to the project of the background task or can it be shared in an other way? 我编写了一个用于管理本地sqlite数据库上的操作的帮助程序类,我是否必须复制该类并将其复制到后台任务的项目中,或者可以其他方式共享? The main goal is to populate the local database in a background thread, triggered by events like TimeZoneChange 主要目标是在诸如TimeZoneChange类的事件触发的后台线程中填充本地数据库

What is the common approach to access classes and references in the main project from a background thread? 从后台线程访问主项目中的类和引用的常用方法是什么? Back in the days of Windows 8 a shared project could be used to share classes via referencing - is this still working on UWP or are there any other recommendations? 在Windows 8时代,共享项目可用于通过引用共享类-这是否仍适用于UWP或有其他建议吗?

This is the current structure of the main project and the background task - I want to use ie DatabaseHelper.cs in the background task 这是主项目和后台任务的当前结构-我想在后台任务中使用ie DatabaseHelper.cs

在此处输入图片说明

Refactor the code so that the code you want to be shared (and its dependencies) are in a separate class library project that both the background task and the app can both reference. 重构代码,以便将要共享的代码(及其依赖项)放在一个单独的类库项目中,后台任务和应用程序都可以引用。

因此,TaskAgent和应用都引用Models程序集

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM