How to avoid circular dependency while adding references to windows runtimecomponent?

user3124361

I added a windows store Blank App,named app, and a windows RTComponent, named backgroundtask, to my project solution. So, I had to add to add references to backgroundtask in app.

But I also needed to use the data input in the app in Backgroundtask. So, I created a class in app and tried to add references to app in Backgroundtask.

It displayed an error stating circular dependency. How can I use the data fed to app through Backgroundtask and add references to Backgroundtask through app all at the same time?

Grant Winney

I'm not sure why Backgroundtask needs to reference app, unless

  • you're trying to access public static variables from the other project, or
  • you're passing an instance of a class from the app project, so Backgroundtask can't access it

Instead, pass the values from app as parameters to whatever method you're calling in Backgroundtask or, if there are a lot of values to pass, create a third project which contains the classes that need to be shared between both projects.

  • Create a project called Shared and reference it from both of the other projects.

  • Add a new class called AppData (or name it something more specific that seems appropriate).

  • Instantiate the class in app, populate it with the data you need, and pass it to a method in Backgroundtask that accepts a parameter of that class type.

Either one of those options should eliminate the need for a circular dependency.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to use @JsonIdentityInfo with circular references?

GSON: how to prevent StackOverflowError while keeping circular references?

How to resolve a circular dependency while still using Dagger2?

RuntimeError: Circular dependency detected while autoloading constant

How to solve the circular dependency

Avoid Circular Dependency injection

How to use forward declaration with boost::msm to avoid circular dependency?

How can i avoid circular references in type aliases

How to avoid circular imports?

How not to get a circular dependency?

avoid circular dependency on hibernate

How to avoid circular dependency in this project?

Circular dependency detected while autoloading constant ORDER

how to avoid heavy dependency

Circular dependency - how to resolve and avoid

How to refactor this to avoid a circular dependency?

Error while adding firebaseui dependency

How to solve Autofac circular dependency?

Typescript/NodeJS - Circular Dependency while working with factories

Vuerouter : need to import, but how to avoid circular dependency?

Issue while adding maven dependency

How to avoid circular dependency with Dagger 2?

How to detect circular references in JavaScript

How to avoid a circular dependency between a GUI and the rest of a program?

How to avoid circular dependency between modules when working with recursive functions?

DAX-Power BI: How to avoid circular dependency in calculated column

How can I avoid circular dependency in my Makefile compiling obj file with g++ and gcc?

How to avoid this circular import?

How to avoid circular dependency in multiple API healthchecks?