views:

34

answers:

1

.NET 4 introduced some types to nicely support cooperative cancellation. I would like to be able to cancel an operation which is running in a different AppDomain. The CancellationToken type is a struct. If I pass it to another AppDomain, will it work as normal?

+1  A: 

I'm not familiar with .NET 4 or cancellation tokens, but the cancellation struct doesn't appear to have the SerializableAttribute so you probably won't be able to get it across the AppDomain boundry in the first place.

You might be able to create a MarshalByRefObject wrapper to do this for you though.

For some reason I thought that structs were always serializable, but it looks like I was wrong.
Daniel Plaisted