Message 1 of 2
ProgressBar doesn't work if its called from another dll
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I have a very strange problem. My solution is made of 3 projects :
- The revit plugin
- A WPF UI project
- A project with process common to multiple application (like Revit, Civil3D, ...).
Each project generate a DLL, all DLLs are in the revit plugin folder. I have a progressBar in the UI project which works when called in the revit plugin project, but didn't works when called from a process in the common project (the progressbar never shown or increment).
In my progressBar i do this :
private Task TaskDoEvent { get; set; }
protected void UpdateTaskDoEvent()
{
if (TaskDoEvent == null) TaskDoEvent = GetTaskUpdateEvent();
if (TaskDoEvent.IsCompleted)
{
Show();
DoEvents();
TaskDoEvent = null;
}
}
private Task GetTaskUpdateEvent()
{
return Task.Run(async () => { await Task.Delay(500); });
}
private void DoEvents()
{
this.Dispatcher.Invoke(() => true, DispatcherPriority.Background);
Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
//Using these lines do the same result
//System.Windows.Forms.Application.DoEvents();
//System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
}
"UpdateTaskDoEvent()" is called when I increment the progressBar.
public void Plus()
{
MainProcessBar.Value++;
UpdateTaskDoEvent();
}
This is the way I called the progressBar.
using (var progressBar = new MyProgressBar(100))
{
for(int i = 0; i < 100; i++)
{
//Do something
progressBar.Plus(); //The progressBar must be shown here
}
}
Does somebody have an idea ? What am I doing wrong ? It's exaclty the same object, from the same dll library, but called from 2 differents locations.
Thanks