How to "transfer" resolved instances from a container to another?
See original GitHub issueI want to achieve the following.
- On a worker thread, an
ExportProvider
resolves one single type and calls one method to retrieve data. E.g.:
var dataLoader = MiniContainer.GetExportedValue<IDataLoader>();
dataLoader.RetrieveData();
-
Meanwhile, on the UI thread, the app’s
ExportProvider
resolves all exported types and values. I.e. regular bootstrapping. -
When the main container is ready, I want to “transfer” the
IDataLoader
instance from the worker thread. That way, the main container can load super-fast.
How can this be achieved? I guess this operation would be equivalent to “as soon as type X is resolved, call X.Foo() in a worker thread, then wait for it after bootstrapping”.
Please advise 😃
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
5 ways to move Docker container to another host
1. Export and import containers · 2. Container image migration · 3. Save and load images · 4. Migrate data volumes · 5....
Read more >Copying data between Docker containers
To copy files from the host to a container one can use the `docker exec` command available since Docker 1.3.0. If have a...
Read more >How to Transfer/Move a Docker Image to Another System?
Moving a Docker image to another system is easy. Use "docker save" to export the image as a TAR file, transfer it to...
Read more >Migrate your Applications to Containers at Scale
Deploy a worker node as an Amazon Elastic Compute Cloud (Amazon EC2) instance. This will include a compatible operating system, which will take ......
Read more >Copy an Amazon EC2 instance
It's not possible to transfer existing instances or AMIs between AWS accounts. Instead, you can manually migrate an EC2 image from one AWS...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes that works, another way to solve it is to not put IDataLoader into the catalog at all. You can have an IDataLoaderProvider in the catalog which will do all the async background stuff, and when its done it publishes the IDataLoader by making it available to others. Everyone would import the IDataLoaderProvider and access the IDataLoader through it, and you can decide how to handle “early access” (eg. blocking, async/await, events, etc.)
Explicitly set the value on an exporting property, yes. After which, any access to that property getter will of course return the value you set it to. That means when MEF accesses that property to get its exported value, it will get the value you set it to. It also means that if MEF accesses that property before you set it, MEF will get the default value instead and assign that to the importer that wanted it. This is the huge limitation of this air-lifting technique. You’d have to be very careful to not activate any MEF part that imports this value until the export has been set.
I don’t know what you mean by this. You’re not preventing the framework from anything.