I've integrated with SP Client and I am calling NewOrder like so.
var progressIndicator = new Progress<ProgressEventArgs>(ReportProgress);
// create a new Order
var order = os.NewOrder(ocs, progressIndicator);
where ReportProgress is defined as
void ReportProgress(ProgressEventArgs e)
{
//Update the UI to reflect the progress value that is passed back.
progressBar1.PerformStep();
}
I've set a breakpoint inside this event, However this code is never called and I never see the Progressbar updated.
the NewOrder call does return and an Order is created.
Any ideas? do I have something not set correctly?
ProgressEventArgs doesn't seem to work on NewOrder
-
- Posts: 1377
- Joined: Wed Jan 15, 2014 3:50 pm
- Location: Raleigh, NC
- Contact:
Re: ProgressEventArgs doesn't seem to work on NewOrder
The progress callback method is only used if templates are being loaded into the order. First the raw order is created. Then, before each template is applied, the callback is updated with a message about which template is about to be loaded, the current template number and the total number of templates. Your code looks correct, but there must not be any templates.
Example usage:
Example usage:
Code: Select all
var progress = new Progress<ProgressEventArgs>( (args) =>
{
// Do something for UI feedback.
});
// Define a new order with two templates.
OrderCreationSpec spec = new OrderCreationSpec();
spec.BaseNumber = "NewOrderNumber";
List<string> templates = spec.Templates;
templates.Add("ABC");
templates.Add("XYZ");
spec.SettlementType = SettlementType.CDF;
// Create the order and pass the progress callback.
IOrderStore os = ss.GetService<IOrderStore>();
IOrder order = os.NewOrder(spec, progress);
Bob Richards, Senior Software Developer, SoftPro
Re: ProgressEventArgs doesn't seem to work on NewOrder
I tried doing this.
var progress = new Progress<ProgressEventArgs>((args) =>
{
progressLabel.Visible = true;
progressLabel.Text = args.Message;
});
ocs.Templates.Add(_selectedTemplate);
// create a new Order
var order = os.NewOrder(ocs, progress);
still did nothing on the event.. no change in my label to show the template was being worked on....
Or does it only work when there are multiple templates?
var progress = new Progress<ProgressEventArgs>((args) =>
{
progressLabel.Visible = true;
progressLabel.Text = args.Message;
});
ocs.Templates.Add(_selectedTemplate);
// create a new Order
var order = os.NewOrder(ocs, progress);
still did nothing on the event.. no change in my label to show the template was being worked on....
Or does it only work when there are multiple templates?
-
- Posts: 411
- Joined: Thu Sep 11, 2008 11:35 am
- Location: Raleigh, NC, USA
- Contact:
Re: ProgressEventArgs doesn't seem to work on NewOrder
In your code example, the GUI would not update because the GUI thread is blocked by the call to create the order. I would recommended placing the create call in a background thread and marshal any GUI updates to the proper thread using a Invoke/BeginInvoke call.
John Morris
Sr. Software Architect
SoftPro
Sr. Software Architect
SoftPro