I have am trying to work with CSLA Silverlight v4 Beta 2 and when I create the async factory methods, the CreateCompleted event never seems to be raised. Is this something that should be done automatically, or do I have to do something in my code to trigger the Event being raised? Below is the code I'm having issues with.
public class Customer : BusinessBase<Customer>
[Obsolete("required by Silverlight Serialization. Do not call manually", true)]
public static void NewCustomer(EventHandler<DataPortalResult<Customer>> callback)
var dp = new DataPortal<Customer>(DataPortal.ProxyModes.LocalOnly);
dp.CreateCompleted += callback;
public class CustomerFactory : ObjectFactory
public Customer Create()
var entity = (Customer)Activator.CreateInstance(typeof(Customer), null);
LoadProperty<Guid>(entity, Customer.IdProperty, Guid.NewGuid());
entity.Name = "Default Name";
public void Can_Create_Customer()
DateTime startTime = DateTime.Now;
bool created = false;
Customer entity = null;
Customer.NewCustomer(delegate(object sender, DataPortalResult<Customer> result)
entity = (Customer) result.Object;
created = true;
Assert.IsTrue((DateTime.Now - startTime) < TimeSpan.FromSeconds(10), "Timeout waiting for DataPortal to create object");
EnqueueCallback(() => Assert.IsNotNull(entity));
EnqueueCallback(() => Assert.IsInstanceOfType(entity, typeof(Customer)));
If you are using the local data portal, then your factory methods must accept a callback parameter, and must invoke that callback - otherwise the data portal has no way of knowing when your factory method has completed (since it assumed to be async).
If you are using a remote data portal, then your code should work, since the factory object would be running on the .NET side, where (at that level) all data portal calls are synchronous.
Copyright (c) Marimer LLC