
The slowness of the creation comes from database lookups and calculations.
Is there any way I can handle the creation of the objects by hand? I would like to use a separate thread.
Thanks!
7 Answers, 1 is accepted
It is impossible to perform pasting on another thread. However, what you can do is handle the Pasting event, cancel it, parse the clipboard input yourself, calculate how many items you need to add, perform your time-consuming operations on another thread and once that's done use the RadGridViewCommands.Paste RoutedCommand to trigger pasting once more. This time the GridView will only replace the values in your existing data items and not create new data items as there are enough rows.
Sincerely yours,
Yavor Georgiev
the Telerik team

I have tried putting code at the beginning of the _Pasting event to update the UI (label, cursor, etc...) to show that there is work being done, but the code does not function until after the Pasting event is complete.
Here is my class, its nothing special:
public class Item_Branch_Vendor_Holder : INotifyPropertyChanged
{
#region
Instantiation
public Item_Branch_Vendor_Holder()
{
}
public Item_Branch_Vendor_Holder(bool DoCurrentCalc)
{
CalculateCurrent = DoCurrentCalc;
}
#endregion
#region
On Changed Events
public virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(
this, new PropertyChangedEventArgs(propertyName));
}
public event PropertyChangedEventHandler PropertyChanged;
#endregion
#region
Private Vriables
private bool CalculateCurrent = true;
#endregion
#region
Properties
bool _blChanged = false;
public bool HasChanged
{
get { return _blChanged; }
set { _blChanged = value; }
}
string _AutoNum = Guid.NewGuid().ToString();
public string AutoNum
{
get { return _AutoNum; }
set { _AutoNum = value; }
}
bool _LoadedFromDb = false;
public bool LoadedFromDb
{
get { return _LoadedFromDb; }
set { _LoadedFromDb = value; }
}
decimal? _Cost = null;
public decimal? Cost
{
get { return _Cost; }
set
{
_blChanged =
true;
_Cost =
value;
if (CalculateCurrent)
{
System.Threading.
ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(Item_Branch_Vendor.GetCurrentValues), this);
}
else
OnPropertyChanged(
"PercentChange");
}
}
decimal? _CurrentCost = null;
public decimal? CurrentCost
{
get { return _CurrentCost; }
set { _blChanged = true; _CurrentCost = value; }
}
int? _Leadtime = null;
public int? Leadtime
{
get { return _Leadtime; }
set { _blChanged = true; _Leadtime = value; }
}
string _ItemNum = String.Empty;
public string ItemNum
{
get { return _ItemNum; }
set { _blChanged = true; _ItemNum = value; }
}
int? _MinOrder = null;
public int? MinOrder
{
get { return _MinOrder; }
set { _blChanged = true; _MinOrder = value; }
}
int? _MaxOrder = null;
public int? MaxOrder
{
get { return _MaxOrder; }
set { _blChanged = true; _MaxOrder = value; }
}
bool? _IsPrimary = null;
public bool? IsPrimary
{
get { return _IsPrimary; }
set { _blChanged = true; _IsPrimary = value; }
}
int? _BranchId = null;
public int? BranchId
{
get { return _BranchId; }
set { _blChanged = true; _BranchId = value; }
}
string _PoNotes;
public string PoNotes
{
get { return _PoNotes; }
set { _blChanged = true; _PoNotes = value; }
}
public string ItemDesc { get; set; }
public string ItemUnitMeasure { get; set; }
public DateTime? DateModified { get; set; }
public DateTime? LastCostChange { get; set; }
private bool _Processed = false;
public bool Processed
{
get { return _Processed; }
set { _Processed = value; }
}
public decimal? PercentChange
{
get
{
decimal? Percent = null;
if (this.CurrentCost.HasValue && this.Cost.HasValue && this.CurrentCost.Value > 0)
{
Percent = 1 - (Cost.Value/CurrentCost.Value);
}
return Percent;
}
}
#endregion
}
Any ideas?
Thanks!
The pasting operation is executed on the same thread, there is no other way, so the UI is blocked. Your best bet would be to follow my previous suggestion - cancel the Pasting event, calculate how many items you need to add and add them to your collection from another thread. Once you have added them, re-trigger the Paste operation from RadGridViewCommands.Paste. This way pasting won't execute any of your data item creation logic.
Greetings,
Yavor Georgiev
the Telerik team

Is this normal?
We have not performed benchmarks of such magnitude, so I'm unable to say. We will try to learn more about this case and let you know.
Best wishes,
Yavor Georgiev
the Telerik team

I'd love to be able to paste asynchronously. <:-)
We have determined that the RadGridView's data engine takes the bulk of the time when pasting such a large number of items into an empty grid. I have created a PITS entry that details a proposal to allow users to create the needed items on their own, rather than going through the data engine. You can vote for it here.
All the best,
Yavor Georgiev
the Telerik team