// Do not remove this try catch block.
-
try
{
Filtering = !filters.IsEmpty;
}
catch(Exception ex)
{
// Do not remove this try catch block. For some reason this always throws Null reference exception but then works.
}
finally
{
Filtering = !filters.IsEmpty;
}Oh My eyes :wtf:
Yusuf May I help you?
-
try
{
Filtering = !filters.IsEmpty;
}
catch(Exception ex)
{
// Do not remove this try catch block. For some reason this always throws Null reference exception but then works.
}
finally
{
Filtering = !filters.IsEmpty;
}Oh My eyes :wtf:
Yusuf May I help you?
I am trying to figure out how that can work. What about
private Something _filters;
private Something filters
{
get
{
if (_filters == null)
{
Task.Run(() => CreateFilters());
}
return _filters;
}
}
private void CreateFilters()
{
// somehow instantiates a Something and sets the _filters member
}That could cause such a strange behavior, couldn't it? :-D
-
try
{
Filtering = !filters.IsEmpty;
}
catch(Exception ex)
{
// Do not remove this try catch block. For some reason this always throws Null reference exception but then works.
}
finally
{
Filtering = !filters.IsEmpty;
}Oh My eyes :wtf:
Yusuf May I help you?
-
I am trying to figure out how that can work. What about
private Something _filters;
private Something filters
{
get
{
if (_filters == null)
{
Task.Run(() => CreateFilters());
}
return _filters;
}
}
private void CreateFilters()
{
// somehow instantiates a Something and sets the _filters member
}That could cause such a strange behavior, couldn't it? :-D
I think he might not know what Multi-Threaded Programming is.
-
try
{
Filtering = !filters.IsEmpty;
}
catch(Exception ex)
{
// Do not remove this try catch block. For some reason this always throws Null reference exception but then works.
}
finally
{
Filtering = !filters.IsEmpty;
}Oh My eyes :wtf:
Yusuf May I help you?
-
try
{
Filtering = !filters.IsEmpty;
}
catch(Exception ex)
{
// Do not remove this try catch block. For some reason this always throws Null reference exception but then works.
}
finally
{
Filtering = !filters.IsEmpty;
}Oh My eyes :wtf:
Yusuf May I help you?
My guess is that either "filters" isn't instantiated or is getting instantiated at the same time that it is being called. What is happening when "IsEmpty" is called? It might be trying to kick something off when it is called.
-
My guess is that either "filters" isn't instantiated or is getting instantiated at the same time that it is being called. What is happening when "IsEmpty" is called? It might be trying to kick something off when it is called.
I second that request. Can we be shown the IsEmpty code please? Can't be too many company secrets hidden in there... god, please say there isn't! :omg:
-
try
{
Filtering = !filters.IsEmpty;
}
catch(Exception ex)
{
// Do not remove this try catch block. For some reason this always throws Null reference exception but then works.
}
finally
{
Filtering = !filters.IsEmpty;
}Oh My eyes :wtf:
Yusuf May I help you?
Outside of that... Who knows the context, but I'm going to guess that filters is a private member property, and Filtering is exposed. Why wouldn't someone just make Filtering a public, get-only convenience property then, rather than setting some piece of data, where we now have to maintain two things?
-
I think he might not know what Multi-Threaded Programming is.
Exactly. But somewhere he read something about lazy initialization, and somewhere else he saw a Task.Run, understood neither of them, and ... Welcome to the wonderful world of code monkeys who've used every programming concept during their career. :^)
-
I second that request. Can we be shown the IsEmpty code please? Can't be too many company secrets hidden in there... god, please say there isn't! :omg:
public bool IsEmpty
{
get {
try {
return _filters.IsEmpty();
}
catch (NullReferenceException e)
{
InstantiateFilters();
throw new NullReferenceException("Try it again now please.");
}
}
} -
try
{
Filtering = !filters.IsEmpty;
}
catch(Exception ex)
{
// Do not remove this try catch block. For some reason this always throws Null reference exception but then works.
}
finally
{
Filtering = !filters.IsEmpty;
}Oh My eyes :wtf:
Yusuf May I help you?
-
try
{
Filtering = !filters.IsEmpty;
}
catch(Exception ex)
{
// Do not remove this try catch block. For some reason this always throws Null reference exception but then works.
}
finally
{
Filtering = !filters.IsEmpty;
}Oh My eyes :wtf:
Yusuf May I help you?
-
Nope. filter is ICollectionView [^](https://msdn.microsoft.com/en-us/library/system.componentmodel.icollectionview(v=vs.110).aspx) type. It is possible it could be null.
Yusuf May I help you?
-
I am trying to figure out how that can work. What about
private Something _filters;
private Something filters
{
get
{
if (_filters == null)
{
Task.Run(() => CreateFilters());
}
return _filters;
}
}
private void CreateFilters()
{
// somehow instantiates a Something and sets the _filters member
}That could cause such a strange behavior, couldn't it? :-D
var filters = Grid.RecordManager.FilteredInDataItems;
it is using 3rd party grid control. It returns ICollectionView [^](https://msdn.microsoft.com/en-us/library/system.componentmodel.icollectionview(v=vs.110).aspx)
Yusuf May I help you?
-
I second that request. Can we be shown the IsEmpty code please? Can't be too many company secrets hidden in there... god, please say there isn't! :omg:
-
public bool IsEmpty
{
get {
try {
return _filters.IsEmpty();
}
catch (NullReferenceException e)
{
InstantiateFilters();
throw new NullReferenceException("Try it again now please.");
}
}
}That tells you everything. You're variously trying to call an IsEmpty() method on a null _filters object. The exception is caught, InstantiateFilters() then fills up your filters variable from your calling code. The next time around in the finally it calls on the IsEmpty property again but this time _filters has been instantiated and the 'try' passes without a problem.
-
That tells you everything. You're variously trying to call an IsEmpty() method on a null _filters object. The exception is caught, InstantiateFilters() then fills up your filters variable from your calling code. The next time around in the finally it calls on the IsEmpty property again but this time _filters has been instantiated and the 'try' passes without a problem.
I'm not the OP so I have no knowledge of the actual code. That was just a stupid joke on my part.